AndEngine – Performance problems with many entities

| | August 4, 2015

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 recently I increase the game width , and by doing so , in the whole level I have about 300 entities (instead of 100+-) But this cause a performance problems , the game is “Lagging” “jumping” and everything move slow.

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 creating from XML as Matin does in his Tutorial:—part-11.html

Is there a better way to handle such multy entities? or a better why to improve the performance?

One Response to “AndEngine – Performance problems with many entities”

  1. 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 :)

Leave a Reply