Sound transmission between cocos2d scenes

Just started working with cocos2d, so far has revealed various scenes, for example, the main menu, settings and much more. Ive added some background music to the main menu scene, for example:

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

The music goes to other scenes, but when I return to the main menu scene, the sound restarts.

I did it only after 3 weeks, so be easy on me :)

Thanks in advance.

+3
source share
1 answer

you should check if background music is playing with [[SimpleAudioEngine sharedEngine] isBackgroundMusicPlaying], and if its playing is currently doing nothing and not calling playBackgroundMusicagain in your main menu

+4
source

Source: https://habr.com/ru/post/1792186/


All Articles