问题描述
刚开始使用 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.
我现在才这样做大约 3 周,所以请放轻松 :)
I have only been doing this about 3 weeks now, so be easy on me :)
提前致谢.
推荐答案
你应该检查当前是否正在播放背景音乐 [[SimpleAudioEngine sharedEngine] isBackgroundMusicPlaying]
,如果它当前正在播放则什么都不做而不是在主菜单场景中再次调用 playBackgroundMusic
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
这篇关于在场景 cocos2d 之间传递音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!