Limiting simultaneous sound streams
Sound playback is generally not a problem when it comes to game performance with AndEngine. However, there are situations where a large number of sounds may play in a very short time-span which can cause a noticeable amount of lag on older and sometimes newer devices depending on how many sounds are playing. AndEngine allows up to five simultaneous sound streams, of the same Sound
object, to play at any given time by default. In this topic, we're going to work with EngineOptions
in order to change the number of simultaneous sound streams in order to better accommodate our application's needs.
How to do it...
In order to increase or decrease the number of simultaneous streams per Sound object, we must make a simple adjustment to EngineOptions
in the onCreateEngineOptions()
method of our activity:
@Override public EngineOptions onCreateEngineOptions() { mCamera = new Camera(0, 0, 800, 480); EngineOptions engineOptions = new EngineOptions(true, ...