• <small id='x3mSL'></small><noframes id='x3mSL'>

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

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

        • <bdo id='x3mSL'></bdo><ul id='x3mSL'></ul>

      1. Cocos2d 播放2种不同的背景音乐文件或循环播放效果

        时间:2024-08-12
          <bdo id='FvTKm'></bdo><ul id='FvTKm'></ul>

                <tbody id='FvTKm'></tbody>
              1. <tfoot id='FvTKm'></tfoot>
                <i id='FvTKm'><tr id='FvTKm'><dt id='FvTKm'><q id='FvTKm'><span id='FvTKm'><b id='FvTKm'><form id='FvTKm'><ins id='FvTKm'></ins><ul id='FvTKm'></ul><sub id='FvTKm'></sub></form><legend id='FvTKm'></legend><bdo id='FvTKm'><pre id='FvTKm'><center id='FvTKm'></center></pre></bdo></b><th id='FvTKm'></th></span></q></dt></tr></i><div id='FvTKm'><tfoot id='FvTKm'></tfoot><dl id='FvTKm'><fieldset id='FvTKm'></fieldset></dl></div>
              2. <small id='FvTKm'></small><noframes id='FvTKm'>

              3. <legend id='FvTKm'><style id='FvTKm'><dir id='FvTKm'><q id='FvTKm'></q></dir></style></legend>

                  本文介绍了Cocos2d 播放2种不同的背景音乐文件或循环播放效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要有一个场景的背景音乐和一个角色的背景音乐,但是当角色做出一些动作时我必须停止它.

                  I need to have to have a background music for the Scene and a background music for an Character,but I have to stop it when the character makes some actions.

                  对于这个问题我不得不选择:

                  For this problem I have to options:

                  1. 同时播放2个背景音乐文件,并停止与角色相关的一个
                  2. 循环播放音效.

                  这其中有 2 种可能 &推荐?

                  Which one of this is 2 possible & recommended?

                  问候!

                  推荐答案

                  你说你在使用cocos2d,所以我假设你也在使用cocos2d提供的SimpleAudioEngine.

                  You say you're using cocos2d so I've made the assumption that you're also using the SimpleAudioEngine provided with cocos2d.

                  使用 SimpleAudioEngine,无法播放 2 个背景音轨.可以通过一些小的修改来循环效果:

                  With SimpleAudioEngine, it's not possible to play 2 background tracks. It is possible to loop effects with some small modifications:

                  • 提供一个-(int) playEffect:(NSString*) file loop:(BOOL) loop消息;
                  • 在这种方法中,您需要了解通常的播放效果是什么.您正在寻找的是用作声音句柄的 ALUInt.保留对此的参考.您需要它来停止循环.
                  • 提供一个 -(void) stopEffectWithHandle:(int) 句柄,将其接收并传递回 OpenAL 以停止效果.
                  • Provide a -(int) playEffect:(NSString*) file loop:(BOOL) loop message;
                  • In this method, you'll need to find out what play effect normally does. The thing you're looking out for is the ALUInt that is used as the handle for the sound. Keep a reference to this. You'll need it to stop the loop.
                  • Provide a -(void) stopEffectWithHandle:(int) handle that takes that in and passes it back to OpenAL to stop the effect.

                  -编辑-

                  下面是一些循环效果的代码:

                  Here's some code for looping an effect:

                  int handle = [[SimpleAudioEngine sharedEngine] playEffect:name];
                  if (loop) {
                      alSourcei(handle, AL_LOOPING, 1);
                  }
                  return handle;
                  

                  还有一些用于停止效果:

                  And some for stopping effects:

                  [[SimpleAudioEngine sharedEngine] stopEffect:handle];
                  

                  这篇关于Cocos2d 播放2种不同的背景音乐文件或循环播放效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:glReadPixel 停止使用 iOS6 Beta 下一篇:如何在使用 cocos2d 的 iphone 应用程序中使用 MYSQL 数据库连接?

                  相关文章

                  1. <legend id='kZy5i'><style id='kZy5i'><dir id='kZy5i'><q id='kZy5i'></q></dir></style></legend>

                  2. <tfoot id='kZy5i'></tfoot>

                      <bdo id='kZy5i'></bdo><ul id='kZy5i'></ul>
                    1. <small id='kZy5i'></small><noframes id='kZy5i'>

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