0

What is the best strategy for SimpleAudioEngine effects preload ? Preload all sound effects at game startup ? Or in each screen's creation preload only the effects used in this screen ? Are loaded effects released at some point ?

Guru
  • 21,652
  • 10
  • 63
  • 102
sdabet
  • 18,360
  • 11
  • 89
  • 158

1 Answers1

2

You preload if playing the sound effect for the first time causes a noticeable lag. For action games you want to preload all gameplay effects. For turn-based or otherwise "slower paced" games it may be ok not to preload any sound effects.

When and where you preload depends on your needs. Typically at the start of a gameplay scene (ie during init or onEnter).

A preloaded effect is not released unless you call unloadEffect on it. Internally the audio engine caches sound effects, so this is not exclusive to preloading. Simply playing a sound effect will also load it and keep it in memory as well.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • So if a preloaded (or just used?) sound effect is not unloaded at some point, will that memory be leaked memory. Example would be a sound effect only used within HelloWorldLayer, and when you go out from that layer (or scene...) the sound effects used in HelloWorldLayer would still linger and the memory would not be usable? – Jonny Mar 21 '13 at 01:18