【问题标题】:SimpleAudioEngine stop music/sound if screen touched如果触摸屏幕,SimpleAudioEngine 停止音乐/声音
【发布时间】:2013-05-11 14:05:06
【问题描述】:

如果用户触摸屏幕,我将如何停止播放音乐/声音。目前声音继续播放到下一个场景。

- (void)setup {

self.isTouchEnabled = YES;
CGSize winSize = [[CCDirector sharedDirector] winSize];

CCSprite *background = [CCSprite spriteWithFile:[AssetHelper getDeviceSpecificFileNameFor:@"StartBackground.png"]];
background.position = CGPointMake(winSize.width / 2, winSize.height / 2);
[self addChild:background];

SimpleAudioEngine *sae = [SimpleAudioEngine sharedEngine];
[sae playEffect:@"airplane_pass.m4a" ];
}

- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[[CCDirector sharedDirector] replaceScene:[CCTransitionFade transitionWithDuration:0.5f scene:[MenuScene scene]]];
}

【问题讨论】:

    标签: xcode cocos2d-iphone simpleaudioengine


    【解决方案1】:

    我通过将以下代码添加到我的 ccTouchesBegan 解决了我的问题

    SimpleAudioEngine *sae = [SimpleAudioEngine sharedEngine];
    [sae unloadEffect:@"airplane_pass.m4a"];
    

    【讨论】:

      猜你喜欢
      • 2016-10-26
      • 1970-01-01
      • 1970-01-01
      • 2017-02-26
      • 1970-01-01
      • 2016-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多