way*_*way 2 audio objective-c cocos2d-iphone ios
我在游戏中使用cocos denshion来播放音乐.我正在播放带有代码的背景音乐:
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"backSong.mp3"];
然而,当游戏结束时,我需要背景音乐逐渐淡出.如何淡出背景音乐,有没有办法做到这一点?提前致谢!另外,ObjectAL是否比CocosDenshion更好?如果是这样,有什么区别/优势?
小智 9
试试这个:
float currentVolume = [SimpleAudioEngine sharedEngine].backgroundMusicVolume;
id fadeOut = [CCActionTween actionWithDuration:1 key:@"backgroundMusicVolume" from:currentVolume to:0.0f];
[[[CCDirector sharedDirector] actionManager] addAction:fadeOut target:[SimpleAudioEngine sharedEngine] paused:NO];
Run Code Online (Sandbox Code Playgroud)
希望有所帮助!
| 归档时间: |
|
| 查看次数: |
2416 次 |
| 最近记录: |