Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


2d animation how?

This topic is 6545 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok this is for direct draw. I need to know how to animate my bitmaps. I have a function that scans my template and loads em in separate surfaces. Right now I have sprite frames on 3 different surfaces. How do I actually get them to blt one after each other?? Please don''t tell me I need velocity speed and crap, I just want to know how to load them continuously. THX!

Share this post

Link to post
Share on other sites
I think the best way is to keep the sprites on one surface (assuming that the surface isn''t too large). Then in your function that scans the source surface and loaded the individual sprites onto different surfaces just keep track of where those sprites are on the surface instead (source rectangles). Then keep a counter for the number of sprites in the animation and the current animation frame. So you could use someting like this:

int numFrames = number of frames in sprite animation;
int curFrame = current frame in sprite animation;

Then when you want to animate the sprite do something like this:

blt using rSourceRectangles[curFrame]

// increment current frame
if(++curFrame == numFrames) // if we are at the end of the animation
curFrame = 0; // reset the the first frame

Let me know if you have any questions.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!