2013-03-27 48 views
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"); 
} 

在这里,它加载的声音,然后触摸按钮时播放。这两个声音在同一时刻。 现在的事情是,我想在我的initScene中加载声音。我用这种方法得到这个:

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

但问题是,当我进入,声音播放,但它始终循环播放。我不知道该怎么做,因为我没有按照无效的第二种声音方法放弃它。有什么问题吗?

回答

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