Skip to main content
GameDev.net gamedev.net
🔒 Locked

Sprite Animation

Started by nanobyte Aug 4, 2001 at 1:51 PM 5 replies 750+ views
Original Post
nanobyte
nanobyte
I am using directx 8 to write my own sprite engine. But I have just one issue to work out and that is animation. I can load an animation sequence and draw it to the screen, the only problem is that it draws each frame on top of the other. For example: int explode[5] = { 1,2,3,4,5}; // animation sequence ship2.Update(); ship2.RenderAnimation(g_pBackSurface, 5, explode); Well, as you can imagine, this draws 5 explosions on top of each other! So my question is, how to I hide the frame before the next one is drawn? Here is the animation function: CSprite::RenderAnimation( LPDIRECT3DSURFACE8 pDestSurface, int numAnimations, int *data) { RECT SourceRect = { 0, 0, m_SpriteWidth, m_SpriteHeight }; POINT DestPoint = { m_x, m_y }; for(int num=0; num
nanobyte
nanobyte
Thanks, that worked! But, now is there a way to hide the animation after I''m done with it? or in other words how do I remove it from the screen after the animation sequence is complete? Thanks.
nanobyte
nanobyte
Thanks everyone! I can sleep now! I promised myself I would not go to sleep until I figured out how to make sprite animation work After struggling for about an hour to set up all the functions right, I finally got everything to work correctly.

Here is the CSprite::Render

if(num SelectActiveSprite(data[num]);
Update();
Render(pDestSurface);
num++;
}
if(num == numAnimations)
visible = false;

So, for every frame, RenderAnimation() is called and num is updated once. Once it finishes, (num==numAnimations), visible is set to false and Render() is set not to draw if visible != true.


Thanks once again!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.