cocos2d 音乐预加载
我如何在cocos2d中异步预加载mp3背景音乐文件?就像纹理一样,
[[CCTextureCache sharedTextureCache] addImageAsync:@"textures.png" target:self selector:@selector(textureLoaded:)];
我只搜索这个解决方案
SimpleAudioEngine *sae = [SimpleAudioEngine sharedEngine];
if (sae != nil) {
[sae preloadBackgroundMusic:@"mula_tito_on_timbales.mp3"];
if (sae.willPlayBackgroundMusic) {
sae.backgroundMusicVolume = 0.5f;
}
}
how i can preload mp3 background music file async in cocos2d? Like textures
[[CCTextureCache sharedTextureCache] addImageAsync:@"textures.png" target:self selector:@selector(textureLoaded:)];
i search only this solution
SimpleAudioEngine *sae = [SimpleAudioEngine sharedEngine];
if (sae != nil) {
[sae preloadBackgroundMusic:@"mula_tito_on_timbales.mp3"];
if (sae.willPlayBackgroundMusic) {
sae.backgroundMusicVolume = 0.5f;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法使用 SimpleAudioEngine 函数异步预加载背景音乐。不过,您发布的解决方案仍然有效,因为 SimpleAudioEngine 数据在 cocos2d 场景之间仍然存在。
如果你确实希望它是异步的,你可以在单独的线程或 NSOperation 中完成它。 cocos2d 论坛上的此帖子提供了许多建议。
You can't preload background music asynchronously using SimpleAudioEngine functions. The solution you posted will still work, though, as the SimpleAudioEngine data persists between cocos2d scenes.
If you really want it to be asynchronous, you could do it in a separate thread, or an NSOperation. This thread on the cocos2d forums has a number of suggestions.