Preload sounds once or on all screen

Hello there!

There’s this function in SimpleAudioEngine :sharedEngine()->preloadEffect(“”), as it’s a shared I suppose I have to preload all the effects once, than I can use them everywhere and they are buffered, still I’m not sure about it so I have to ask: do I need to preload the effects on every scene? Or just on in the AppDelegate.cpp file?

Other question: do I have to call the end function before closing the app? I saw a tutorial on raywenderlich.com about cocos2d-x game, and the developer didn’t mentioned about it but in the reference it says it can lead to a memory leak (not calling it).

Thanks

Yes you only need to “preloadEffect()” once. I do this in my init() as my app is loading, your choice when/where you do it.

Ending your app with a call to CCDirector::sharedDirector()->end();
If you’re on iOS then there is no need to call End(), it is all that multitasking and app in the background stuff (see Apples docs).
If you are on Android/Windows or similar then I think you should have an exit button and call “CCDirector::sharedDirector()->end();”. On my Android version I have an exit button on the topmost main menu.

On Android there is of course the back button that you could overload the callback, but I found it didn’t work so went with my on screen button. Also, on Android there is a hardware home button that takes the user to the desktop and puts your app to sleep (no “end”).

See here for more Android Back button talk: http://www.cocos2d-x.org/boards/6/topics/3132

Okay, thanks a lot for your answer :wink: