I'm developing a rolling scene based game. I'm loading all the entities from a XML file and create them in the Loading Scene.

I recently increased the game width, and, by doing so, I now have about 300 entities (instead of about 100) in the whole level. This causes a performance problem: the game is "Lagging" \ "jumping" and everything moves slowly.

I'm loading the entities with the "LevelLoader".

I tried to add:


before returning the object in :

public IEntity onLoadEntity(final String pEntityName, final Attributes pAttributes){...}

and also set Dithering in the engineOptions:


but it didn't help...

I'm implementing the sprite created from XML as Matin does in his tutorial:


Is there a better way to handle such a high number of entities? Or is there another way to improve the performance?

  • \$\begingroup\$ Are there more details about your implementation that you can reveal? From what you've posted it's very difficult to pin-point your problem. As sm4 pointed out, a SpriteBatch can help you, but only under certain circumstances and without knowing more about your application providing relevant suggestions will be impossible. \$\endgroup\$ – bornander Oct 9 '14 at 13:09

The good news is that there are many things that you can do. Bad news - there's no magic switch to set to true to make your game run faster.

  1. Make sure that whatever you are doing in a loop is optimized. For example if you check in each loop cycle for some difficult condition for each sprite.
  2. Dithering won't help you. Please first understand what it does :)
  3. Culling helps a lot, but it is turned on by default, so you don't have to turn it on yourself
  4. Instead of using many sprites (300 is not that much though), try SpriteBatch. This should help you the most in this case. I suppose you use a lot of entities that look the same. There's when the Sprite batch comes handy.

I expect you now ask: How to use the SpriteBatch? Well the link explains it, so please first go through the code there, try to understand it, implement it and if you hit a wall again, ask a new question specifically about it :)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.