0

我已经实现了加载我声音数组的方法:

-(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");
}

在这里,它加载声音,然后在触摸按钮时播放。2声,同时响起。问题是现在,我想在我的 initScene 中加载声音。我用这种方法得到这个:

[self schedule:@selector(soundSuper) interval:2];

但问题是当我进入时,声音播放,但它一直在循环。我不知道该怎么办,因为我已经在void第二声音方法上取消了它。有什么问题吗?

4

1 回答 1

1

你不认为你应该也取消安排“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];
}
于 2013-03-27T17:14:02.020 回答