Directly manage movieclip drawing. AS3
So, I'm wondering if it's possible to stop all animation, do computations such as "moving a bunch of enemies movieclips, moving some bullets, etc.", then starting the animation again so that all of the drawing would occur at once.
My application would be in the game loop of my game. The problem I'm having is that I have around 50 enemies on screen, all开发者_StackOverflow社区 of which are moving very fast, and I walk through the array and move each MovieClip. There's some lag and I'd like to get rid of it in any way I can.
If I understand AS3 correctly, it would try to draw to the screen after each change of the X and Y value of each MovieClip. By stopping animation, setting these values, then starting it up again, I think I'd increase performance by quite a bit.
If performance is your goal, you may want to think about dropping MovieClips (which are quite expensive) for bit-blitting. Essentially you're calculating movement, collision, et al and then doing one draw into a bitmap canvas instead of drawing each MovieClip.
Replacing any vector art with Bitmaps will significantly speed up your render as well. Try to use as few frames as possible. Check out 8bitrocket for more on Blitting.
Flash renders each frame once. You can move stuff around all you want "between" frames. So, the way you are moving your enemies now is the proper way.
Using blitting is sort of the nuclear option, you gain a lot performance wise but you'll also loose many of the benefits flash gives such as rotation/scaling and the mouse/interactivity bit.
It's hard to give any other pointers without seeing the game, but generally, try to avoid transparency over large areas, masking can be expensive and filters can be heavy to render.
精彩评论