Skip to main content
gamedev.net
🔒 Locked

2D Animation Problem

Started by rajivtm 3 replies 400+ views
Original Post
rajivtm
rajivtm
I am new to DirectX 9 and C#, but I have been learning it over the past few months as I make a 2D game. There are still some things that are fuzzy for me, so I hope someone can help clear them up. My game works great until a few minutes into it when the bitmaps get all fuzzy and unreadable. Sorry I can't be more descriptive on how they look, but it just looks like they have been corrupted. There are a lot of animations in my game, and I think the problem is that each time I switch to a new frame of the animation, I create a new surface for the BitmapObject, which doesn't seem right to me. Is it? It seems like there should be a way to take my BitmapObject's Surface and just set the sourceBitmap. The only way I can figure out to do it is to make a new instantiation of the Surface with the next frame as the sourceBitmap. Is there a better way to do it? Please let me know if you need any more information from me. Thanks for any help you can give me!! Rajiv
Zook
Zook
Creating a new surface each frame doesn't sound like a good idea. You could have a pointer to a surface and just change what it's pointing to when you want to change frame. I don't know if that will solve this particular problem though.
rajivtm
rajivtm
That might work. So you're saying if the animation I use most often only has 6 frames, I could create 6 surfaces at the beginning of the game and just switch between them during the animation? Has anyone tried this before? Is there another alternative?
lack o comments
lack o comments
Quote:
...Has anyone tried this before?

Yes, this technique has been around since... well... computer animation =)

As far as alternatives, there are plenty. One such method would be to place several images into a single surface, and then only copy the section of the surface that contains the image for the current frame.
rajivtm
rajivtm
Awesome!! Thanks for your input!!

Topic Locked

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

Sign in to reply to this topic.