I’m working on a game thats graphically very simple. There are some hexagons in the background for walls. All the enemies are circles, and all the bullets and projectiles are smaller circles. Granted, sometimes there are quite a few circles on the screen, but I would say its a much simpler Flash game than most of the ones out there.
However, for some reason my game gets pretty slow pretty quickly as soon as there are lots of circles moving around on screen. I’ve done a ton of profiling and determined that its the rendering phase thats causing the real slowdown. I’ve got profiling code (stopwatches) around all of my game code and its telling me that each game update takes about 5-10 milliseconds which is acceptable. However I also have a profiler which tracks the time between calls to ENTER_FRAME handler (so this is everything other than my game code, i.e., the render step). At the start of the game when not much is happening, this is 10 milliseconds. In the middle of a level when lots of circlees are flying around, this becomes 30-40 millieconds, which is way too slow.
I’ve done a lot of reading and experimentation to try to make it faster. I’m using Shapes instead of Sprites wherever possible (so almost all of the circles). I’m using Sprites instead of MovieClilps (I have zero MovieClips actually). I’m using cacheAsBitmap = true for all graphics that will not be changing (so again, basically all of my circles). I’m using mouseEnabled = false for just about every Sprite. I’m using object pools for the bullets and enemies, so I’m never creating new objects in the middle of a game, only setting their visibility on and off.
But for some reason the game gets choppy and slow fairly quickly once there are a lot of circles (enemies and bullets) flying around. An obvious solution is to reduce the number of enemies and/or bullets, but I really dont want to do that. I know I’ve seen Flash games with way more happening on the screen than my game has. So I don’t want to dumb down my game (its dumb enough already haha) - I want to figure out where the bottleneck is and make it faster.
Any tips would be greatly appreciated!