2013-05-11 106 views
1

如果用戶觸摸屏幕,我將如何停止播放音樂/聲音。目前聲音繼續播放到下一個場景中。SimpleAudioEngine在觸摸屏幕時停止音樂/聲音

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

回答

0

我通過添加下面的代碼到我的ccTouchesBegan解決我的問題

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