PDA

View Full Version : Blitting problem - Rotation and frame based animation


mshadows
03-16-2010, 06:59 PM
Hi guys,

I couldn't find anything whilst searching the forums and I'm at a loss to explain what's happening myself so I thought I would post to see if anyone can help me out, thanks in advance.

I've been designing a game engine based on one I found online (here (http://www.brighthub.com/internet/web-development/articles/11010.aspx)). This engine uses double buffering and copypixels to draw bitmapData to the screen, and it also has frame based animations going on too. I wanted to extend this to allow for rotating these animations.

I wanted to rotate the bitmapData in question (a character on screen for example) and then copyPixels it to the screen. I ran into a lot of trouble with this. After a lot of research and experimentation, what I eventually ended up doing was a lot of prerendering on each frame in my animation, so that I had a copy of it at all angles (well at intervals of 5 degrees). Then what I would do is blit in the correct frame of the animation and rotation onto the screen.

This is great and works a treat... Almost. When the image is not at a 90 degree angle it will kind of flicker. I have no idea why this is, i can only think that the matrix transformation i perform on the image when rotating it produces different results on the same image, but that doesn't make sense to me. Can anyone shed any light?

I have attached my SWF and also the corresponding frame based animation, this should make my problem clear.

Mshadows

TomMalufe
03-16-2010, 07:35 PM
This is a little confusing. Why can't you just use MovieClips? Why do you need to draw everything to a bitmap with a transform?

asgrunt
03-16-2010, 08:19 PM
don't know how you did the blitting but I doubt that this is the reason for the flickering graphics. However, if you want perfect and smooth rotation, put it into the spritesheet itself. Then you don't need to rotate the sprite on stage. Its just copypixel, nothing else.

Hi TomMalufe,

there are several reasons for using bitmaps instead of mcs. To name but a few:

- performance
- direct access to pixels
- flexibility (easily change the spritesheets to get new content)

If you want to know what can be done this way look at 8bitrocket.com.

mshadows
03-17-2010, 12:20 PM
Hi both, thanks for you help,

asgrunt has my reasons for doing it but I probably explained my issue badly =]

I will try putting my rotations on the sprite sheet itself and post back here with my results.