1

How would I stop the music/sound from playing if the user touches the screen. currently the sound continues to play out into the next scene.

- (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]]];
}
Guru
  • 21,652
  • 10
  • 63
  • 102
acctman
  • 4,229
  • 30
  • 98
  • 142

1 Answers1

0

i solved my problem by adding the code below to my ccTouchesBegan

SimpleAudioEngine *sae = [SimpleAudioEngine sharedEngine];
[sae unloadEffect:@"airplane_pass.m4a"];
acctman
  • 4,229
  • 30
  • 98
  • 142