• <i id='RDDU1'><tr id='RDDU1'><dt id='RDDU1'><q id='RDDU1'><span id='RDDU1'><b id='RDDU1'><form id='RDDU1'><ins id='RDDU1'></ins><ul id='RDDU1'></ul><sub id='RDDU1'></sub></form><legend id='RDDU1'></legend><bdo id='RDDU1'><pre id='RDDU1'><center id='RDDU1'></center></pre></bdo></b><th id='RDDU1'></th></span></q></dt></tr></i><div id='RDDU1'><tfoot id='RDDU1'></tfoot><dl id='RDDU1'><fieldset id='RDDU1'></fieldset></dl></div>
    • <bdo id='RDDU1'></bdo><ul id='RDDU1'></ul>

      <small id='RDDU1'></small><noframes id='RDDU1'>

    1. <tfoot id='RDDU1'></tfoot>

        <legend id='RDDU1'><style id='RDDU1'><dir id='RDDU1'><q id='RDDU1'></q></dir></style></legend>

      1. CocosDenshion 音乐淡出

        CocosDenshion music fade out(CocosDenshion 音乐淡出)
          <tbody id='DMPNS'></tbody>
        <legend id='DMPNS'><style id='DMPNS'><dir id='DMPNS'><q id='DMPNS'></q></dir></style></legend>

        <small id='DMPNS'></small><noframes id='DMPNS'>

        • <i id='DMPNS'><tr id='DMPNS'><dt id='DMPNS'><q id='DMPNS'><span id='DMPNS'><b id='DMPNS'><form id='DMPNS'><ins id='DMPNS'></ins><ul id='DMPNS'></ul><sub id='DMPNS'></sub></form><legend id='DMPNS'></legend><bdo id='DMPNS'><pre id='DMPNS'><center id='DMPNS'></center></pre></bdo></b><th id='DMPNS'></th></span></q></dt></tr></i><div id='DMPNS'><tfoot id='DMPNS'></tfoot><dl id='DMPNS'><fieldset id='DMPNS'></fieldset></dl></div>

          <tfoot id='DMPNS'></tfoot>
              • <bdo id='DMPNS'></bdo><ul id='DMPNS'></ul>

                  本文介绍了CocosDenshion 音乐淡出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

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

                  I'm using cocos denshion for the music in my game. I'm currently playing background music with the code:
                  [[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"backSong.mp3"];
                  However, when the game ends, I need the background music to fade out gradually. How can I fade out the background music, is there a way to do this? Thanks in advance! Additionally, is ObjectAL any better than CocosDenshion? If so, what are the differences/advantages?

                  推荐答案

                  我发现这样做的唯一方法是安排一个执行方法并相应地更改音量设置,如下所示:

                  The only way i found of doing that is to schedule a method for execution and change the volume setting accordingly, kind of as follows:

                  -(void) fadeOutBackgroundMusic{
                      if (!currentBackgroundMusic_) {
                          CCLOG(@"GESoundServicesProviderImpl<fadeOutBackgroundMusic> : No background music at this time, ignoring.");
                          return;
                      }
                  
                      fadeOutActionTickerCount_=0;
                      [self schedule:@selector(tickMusicFadeOut:)];
                  
                  }
                  
                  -(BOOL) isPlayingBackgroundMusic{
                      return isPlayingBackgroundMusic_;
                  }
                  
                  #pragma mark sequencing stuff
                  
                  -(void) tickMusicFadeOut:(ccTime) dt{
                  
                      static float fadeTime;
                      static float volume;
                      static float maxVolume;
                  
                      fadeOutActionTickerCount_++;
                      if (1==fadeOutActionTickerCount_) {
                          isPerformingFadeOutAction_ =YES;
                          fadeTime=0.0f;
                          volume=0.0f;
                          maxVolume=audioSettings_.masterVolumeGain*audioSettings_.musicCeilingGain;
                  
                      } else {
                  
                          fadeTime+=dt;
                          volume=MAX(0.0f, maxVolume*(1.0 - fadeTime/K_MUSIC_FADE_TIME));
                          [self setMusicVolume:volume];
                  
                          if (fadeTime>K_MUSIC_FADE_TIME) {
                              volume=0.0f;                        // in case we have a .000000231 type seting at that moment.
                          }
                  
                  
                          if (volume==0.0f) {
                              CCLOG(@"GESoundServicesProviderImpl<tickMusicFadeOut> : background music faded out in %f seconds.",fadeTime);
                              [self setMusicVolume:0.0f];
                              [sharedAudioEngine_ stopBackgroundMusic];
                              self.currentBackgroundMusic=nil;
                              isPlayingBackgroundMusic_=NO;
                              isPerformingFadeOutAction_=NO;
                              [self unschedule:@selector(tickMusicFadeOut:)];
                          }
                      }
                  
                  }
                  

                  这是来自我的声音服务提供者实现类的简化(编辑)示例(未测试,如此处所示).一般的想法是为自己安排一个在一段时间内逐渐淡出音乐的方法(这里是一个应用范围的常量,K_MUSIC_FADE_TIME).

                  this is a simplified (edited) sample from my sound services provider implementation class (not tested as shown here). The general idea is to schedule yourself a method that will gradually fade out the music over a period of time (here an app-wide constant, K_MUSIC_FADE_TIME).

                  这篇关于CocosDenshion 音乐淡出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
                  Resume game cocos2d(恢复游戏 cocos2d)
                  Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
                  How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)
                  Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)
                    <tbody id='wENjn'></tbody>
                  <legend id='wENjn'><style id='wENjn'><dir id='wENjn'><q id='wENjn'></q></dir></style></legend>
                  • <i id='wENjn'><tr id='wENjn'><dt id='wENjn'><q id='wENjn'><span id='wENjn'><b id='wENjn'><form id='wENjn'><ins id='wENjn'></ins><ul id='wENjn'></ul><sub id='wENjn'></sub></form><legend id='wENjn'></legend><bdo id='wENjn'><pre id='wENjn'><center id='wENjn'></center></pre></bdo></b><th id='wENjn'></th></span></q></dt></tr></i><div id='wENjn'><tfoot id='wENjn'></tfoot><dl id='wENjn'><fieldset id='wENjn'></fieldset></dl></div>
                  • <small id='wENjn'></small><noframes id='wENjn'>

                        <tfoot id='wENjn'></tfoot>

                          <bdo id='wENjn'></bdo><ul id='wENjn'></ul>