我希望按照数组的顺序播放声音。如果第一个声音结束,第二个声音应播放,依此类推......
下面你可以看到我把声音包装在一个子类中的数组中:
@implementation Level
{
SKAction *_s1;
SKAction *_s2;
SKAction *_s3;
SKAction *_s4;
}
- (instancetype)init
{
self = [super init];
if (self) {
_s1 = [SKAction playSoundFileNamed:@"SoundOne.mp3" waitForCompletion:YES];
_s2 = [SKAction playSoundFileNamed:@"SoundTwo.mp3" waitForCompletion:YES];
_s3 = [SKAction playSoundFileNamed:@"SoundThree.mp3" waitForCompletion:YES];
_s4 = [SKAction playSoundFileNamed:@"SoundFour.mp3" waitForCompletion:YES];
_oneArray = @[_s1, _s1, _s2, _s2, _s3, _s4];
}
return self;
}
然后我通过声音将数组传递到主场景。如下所示:
@implementation GameScene
{
Level *_level;
NSArray *_levelOne;
}
-(void)didMoveToView:(SKView *)view {
// setup level class
_level = [[Level alloc] init];
_levelOne = _level.oneArray;
SKAction *one = [SKAction sequence:@[_levelOne]];
[self runAction:one];
感谢所有帮助。
答案 0 :(得分:0)
这将播放所有声音1乘1
somecolumn;
C F;