gpt4 book ai didi

objective-c - CocosDenshion音乐淡出

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:54:58 25 4
gpt4 key购买 nike

我在游戏中使用 cocos denshion 作为音乐。我目前正在使用代码播放背景音乐:
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"backSong.mp3"];
但是,当游戏结束时,我需要背景音乐逐渐淡出。我怎样才能淡出背景音乐,有没有办法做到这一点?提前致谢!此外,ObjectAL 是否比 CocosDenshion 更好?如果是这样,有什么区别/优势?

最佳答案

试试这个:

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];

希望对您有所帮助!

关于objective-c - CocosDenshion音乐淡出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10691897/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com