Passing audio between scenes cocos2d(在场景 cocos2d 之间传递音频)
问题描述
刚开始使用 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 之间传递音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在场景 cocos2d 之间传递音频
基础教程推荐
- 如何从 logcat 中删除旧数据? 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- iOS4 创建后台定时器 2022-01-01
