我已经实现了加载声音数组的方法:
-(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");
}
这里,它加载声音,然后在触摸按钮时播放。两声同时响起。 问题是,现在我想将声音加载到我的 initScene 中。我用这种方法得到了这个:
[self schedule:@selector(soundSuper) interval:2];
但问题是,当我进入时,声音会播放,但它一直循环。我不知道该怎么办,因为我已将其取消在 void Second Sound 方法上。有什么问题吗?
最佳答案
您是否认为您也应该取消安排“soundSuper”选择器,就像这样
-(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];
}
关于ios - 声音一直循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15660047/