Reputation: 399
I have implemented to methods that loads me array of sounds:
-(void) soundSuper
{
[soundEngine stopAllSounds];
[soundEngine playSound:(1000+tag) sourceGroupId:1 pitch:1 pan:1 gain:1.0f loop:NO];
NSLog(@"sound1 activated");
[self schedule:@selector(playSecondSound) interval:2];
}
-(void) playSecondSound {
[self unschedule:@selector(playSecondSound)];
[soundEngine playSound:(1008+tag) sourceGroupId:1 pitch:1 pan:1 gain:1.0f loop:NO];
NSLog(@"sound2 activated");
}
here, it loads the sound and then is played when touching a button. The 2 sounds, at the same moment. The thing is that now, I want to load the sound in my initScene. I am getting this with this method:
[self schedule:@selector(soundSuper) interval:2];
but the problem is that when I enter, the sound is played, but it loops all the time. I don't know what to do, because I have unshedule it on the void second sound method. Is something wrong?
Upvotes: 0
Views: 61
Reputation: 1175
Dont you think you should unschedule the "soundSuper" selector also, like this
-(void) soundSuper
{
//HERE : you unschedule this selector too.
[self unschedule:@selector(soundSuper)];
[soundEngine stopAllSounds];
[soundEngine playSound:(1000+tag) sourceGroupId:1 pitch:1 pan:1 gain:1.0f loop:NO];
NSLog(@"sound1 activated");
[self schedule:@selector(playSecondSound) interval:2];
}
Upvotes: 1