Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing audio between scenes cocos2d

Just started working with cocos2d, so far ive set up different scenes eg main menu, settings and about. Ive added some background music to the main menu scene like so:

    [[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"TileMap.caf"];

The music passes through to the other scenes, but when i go back to the main menu scene the sound restarts itself.

I have only been doing this about 3 weeks now, so be easy on me :)

Thanks in advance.

like image 954
user506926 Avatar asked May 10 '26 16:05

user506926


1 Answers

you should check if background music is currently playing with [[SimpleAudioEngine sharedEngine] isBackgroundMusicPlaying], and if its currently playing just do nothing instead of calling playBackgroundMusic again in your main menu scene

like image 65
JonLOo Avatar answered May 12 '26 06:05

JonLOo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!