Hello Steve!
What is the best way to use CDSoundEngine.
I have a game. Game has MainMenuScene, IntroScene, GameScene, HelpScene, ...
I have to play background music and sound fx on each scene.
I have a two ways to implement sound
The first way is create and init CDSoundEngine on each scene, like this
@interface MainMenuLayer : Layer
{
CDSoundEngine *soundEngine;
}
@end
@implementation MainMenuLayer
- (id) init
{
...
soundEngine = [[CDSoundEngine alloc] init ...];
[soundEngine loadSounds...];
...
}
- (void) dealloc
{
[soundEngine release];
...
}
- (void) onEnter
{
[soundEngine playSound...];
}
- (void) onExit
{
[soundEngine stopSound...];
}
@end
The second way is to create, init and destroy CDSoundEngine in AppController and use soundEngine variable in each scene.
May be there is the third way.
What do you think?
Thanks