Optimization of AndEngine game

前端 未结 6 1954
南旧
南旧 2021-02-01 09:06

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:

6条回答
  •  南方客
    南方客 (楼主)
    2021-02-01 09:53

    You're probably going to need to post some more specific information about your game but one suggestion is to make sure you are re-using sprites and objects. For example if your game has any type of object that is repeatedly generates (random flying enemies, bullets, repetetive background elements) try to think about the maximum amount of that object that you will need on the screen at one time and then create that many before game play starts, loading and resetting them as you need.

    For instance my game uses enemies that "randomly" fly in from the top of the screen. At first I was making a new enemy with each call but now I have an ArrayList that contains only 6 enemies in total which get reused and moved around hundreds of times each. This resulted in a HUGE performance gain for me, especially in longer game sessions. This is related to the GC optimization but something that you might not have though about optimizing before.

提交回复
热议问题