Results 1 to 7 of 7

Thread: SpriteEngine (Draw transparent).

  1. #1

    SpriteEngine (Draw transparent).

    Yes another question, to be honest I haven't tried this yet, but I'm not much sure on how to go about it, if it is possible.

    So I have a sprite player walking around and doing what ever.

    And as a Sprite of it's own (purely to handle the animation of it for me) the Arrow that resides of the players head (I'm sure most of you have seen this in a number of games).

    I would like to somehow tell the SpriteEngine, to draw this arrow with transparency so what is underneath it while animating can be seen.

    For example his attacks while facing upward, or just other objects below it (not so important, but it would be nice mostly to be able to see his attacks beneath it).

    I'm not sure if the arrow indicator will be much use with w/e transparency I will need to see reasonably underneath it, but that's one thing I want to find out.

  2. #2

    SpriteEngine (Draw transparent).

    override the draw procedure and use drawalpha there,
    if you goggle around you can find tutorial about that like celebral byclicle site etc.. for make simple games and sprite engines with delphix
    Will: "Before you learn how to cook a fish you must first learn how to catch a fish." coolest

  3. #3

    SpriteEngine (Draw transparent).

    So basically, by overiding the draw procedure and using drawalpha, it's the same as letting it draw itself (aside from the fact that I am now using drawalpha, instead of letting it plain draw).

    Just wanting to confirm that there is/isn't anything else to it.

    I'll go have a look at that site (haven't checked it out in awhile).

  4. #4

    SpriteEngine (Draw transparent).

    UPDATE:

    Ok I have over ridden the DoDraw procedure for my TArrow object.

    It draws with transparency, but does not animated like usual.

    Hoping for sheer luck, I added "Inherited DoDraw;", and it drew the static alpha transparent image, and then the normal *animated* one overtop lol.

    Got any advice on how I can fix this up? There's probably some manual code to go into the DoDraw procedure I would assume.

  5. #5

    SpriteEngine (Draw transparent).

    well, the reason it's rendering the non-transparent version on top is probably because you're calling inherited in the code after you draw the arrow..

    As for the animation not working, well.. the DoDraw function in TImageSprite.DoDraw; gets the image to draw from the animation using some variables which are private.

    Try using something like this

    [pascal]

    procedure TMySprite.DoDraw();
    var
    SpriteRect : TRect;

    begin

    SpriteRect.Left :=round(x);
    SpriteRect.Right := SpriteRect.Left+width;
    SpriteRect.Top := round(y);
    SpriteRect.Bottom := SpriteRect.top +height;

    image.DrawAlpha( Engine.Surface,SpriteRect,round(animpos),AlphaValu e);

    end;

    [/pascal]

    Hopefully, this should retain the animation.

  6. #6

    SpriteEngine (Draw transparent).

    Not need!!

    Just inherited from TImageSpriteEx.

  7. #7

    SpriteEngine (Draw transparent).

    DraculaLin, could you explain what you mean? the above isn't needed or the idea of overriding DoDraw.

    I'm using the post above yours solution for now, seems to work well .

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •