wood burning stoves 2.0*
The moose likes Flex and the fly likes Blitting animation stutters when I get about three levels deep Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Flex
Bookmark "Blitting animation stutters when I get about three levels deep" Watch "Blitting animation stutters when I get about three levels deep" New topic

Blitting animation stutters when I get about three levels deep

Alvin Watkins
Ranch Hand

Joined: May 25, 2011
Posts: 53
I have been asked to help a client solve a game problem where the app keeps stuttering during gameplay. The game is currently a MovieClip based game where a parent is added to stage and children are made visible/invisible based on things happening during the game. For instance, if the character is hit by a paint ball, the character will update with a paintball stain. So, there is a clean version of the character plus a stained version where they can be overlayed (clean under stained) and stains made visible as they need be.

The background can also be stained when the character is missed. Lots of stains accumulate during game play. As they begin to add up, the frame rate drops and the game starts stuttering.

I thought I'd be clever and fix this by blitting. I created a blit engine that will take sprite sheets (or convert MC to sprite sheets) and simply overlay them on top of each other. I also built a tweening system that moves the character along the x axis based on walking frames. I use a static sprite sheet for the clean character and then generate other sprite sheets in memory as they are needed (such as when the character gets hit by a paint ball).

Unfortunately, I am not finding this is necessarily smoother. I am finding that once I get about 3 layers deep on the z axis, the frame rate rises and falls. My code for the blitting portion is:

I'm happy to show more code if needed. Does anyone have any ideas why the blitting is slowing down as I add to the z access?

Also, I have noticed that if I add all these pixels to the display and then let the blitting run through a few iterations, I seem to have less stuttering then. That makes no sense to me as the canvas is redrawn from frame to frame and the old drawing is completely erased between frames... For some reason, the Timer seems to run more smoothly after it has run for a little while.

Thanks for any help you can give me on smoothing out my blitting animations.
I agree. Here's the link: http://aspose.com/file-tools
subject: Blitting animation stutters when I get about three levels deep
Similar Threads
sprite question
using constructors in gui programs
Dragon Ball Z Fans
Double Buffering Problem