Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Optimization of AndEngine game

I am using java + AndEngine in my game.

During the game i have some freezes, i looked for the information and found some steps how to optimize game performance:

  1. Avoid GC (garbage collector) to be called in main action in the game:
    a)don't create objects while gaming;
    b)don't create unnecessary objects;
  2. Optimize code that repeats very often

I followed these steps, but never the less i have some freezes during the gameplay.

Now i am creating and loading all of the textures before the game started and don't unload them, is it a bad idea ? How can i optimize the game proccess ? Maybe i have to make free all of the possible memory before main activity and then reload them after each level ?

like image 412
dilix Avatar asked May 28 '11 16:05

dilix


2 Answers

  1. Reduce texture sizes.
  2. Reduce texture switches (aka try to use spritesheets, so that the texture needs to be changed as few as possible)
  3. Use lower quality textures (RGBA4444 or RGB565 instead of RGBA8888)..
  4. Call setIgnoreUpdate where the entity doesn't need updates.
  5. Use SpriteBatches if possible.

FYI: The next version of AndEngine (coming mid december) sports GLES2 so you have a lot more possibilities to improve performance with custom Shaders and Entities.

Also it will execute the startup pipeline (onLoadEngine/onLoadResources/onLoadScene/onLoadComplete) on the first frame of the GL-Thread, instead of blocking, on the UI-Thread (directly in onCreate).

Also it allows you to easily offload the stages of the pipeline into Threads, without breaking the pipeline as a whole. There will be a very simple to implement subclass of BaseGameActivity that shows a determinate ProgressDialog while the stages of the pipeline are executed. Entities will pop in the as they are attached to the scene.

In general this means, the actual loadingtimes are reduced, and more importantly, the felt loadingtimes are reducedsignificantly! Creating a loading-screen is trivially easy, as opposed to the pain it was before.

like image 94
Nicolas Gramlich Avatar answered Oct 10 '22 02:10

Nicolas Gramlich


You can increase performance using AndEngine: Using the Object Pool http://c0deattack.wordpress.com/2011/01/06/andengine-using-the-object-pool/

like image 21
AZ_ Avatar answered Oct 10 '22 04:10

AZ_