alright lets check this out again - havent worked on this game since
Debug your sprite batch with renderCalls to find out how many times per frame it's rendering/flushing.
1 2 3 4 5 6 7
| batch.totalRenderCalls = 0;
Display.setTitle("Calls: "+batch.totalRenderCalls); |
Things that flush the batch:
- Using a different texture
- Changing the shader
- Changing the projection matrix
- Changing the view/transform matrix
- Rendering more sprites than the batch size allows
Ok I get kinda 9 on average and like 16 if everything explodes (bomb)
For example, you should only change the projection matrix when the viewport/display is resized.
How do you do HUDs ?
I use a second camera and change projection matrix to it for HUD, when everything else was rendered.
I only have 2 textures (excluding the particle pngs), basically only 1, just the explosion effect is a large image getting bigger so this one is a texture by itself
Other things to keep in mind:
- Use nearest neighbour filtering where possible to improve performance
- Minimize overdraw; i.e. for blending effects, use a shader instead of drawing sprites many times over each other
- Try changing resolution... If the FPS improves dramatically, it may be an indication that your game is fill-rate limited.
- Put an option to cap your particles, e.g. a slider UI, and try testing that on your Android to see if reducing particle count improves performance. If that's the case, it may be another indication that you are fill-rate bound
Resolution well... I dont really have a problem on a low end PC, just android devices, but they even have 2 cores...
Im gonna try on my single core laptop to check out the performance there...
yes particles - I will double check, but I'm pretty positive that its not particles because I made this performance test:
I just stood still - enemies will come and corner you, and shoot - the hits on you is just a color filter going red on the player sprite
as more enemies approached it got slower
also going to check out on my new Galaxy S3, but I don't expect it to lag there.
Also different issue, well not really maybe, might be related.
For many reasons I wanna avoid delta timing stuff, so we have in all our games a 60 fps mode for desktop and a 30 fps mode for mobile where we just move everything twice as fast and do forth - because you can never know what the vsync fps is going to be on mobile
and my method of frame throttling may be suboptimal