运行运行void语句SpriteKit的SKAction

时间:2014-07-14 04:44:56

标签: xcode5 sprite-kit void skaction

我正在尝试运行粒子节点或仅在调用某个动作时运行一个节点,但我不确定要使用哪个动作,或者我是否正确行事。

我没有运气地搜索苹果的文档。

这就是我的尝试:

    -(void)setupbabyFireNode{
    NSString *babyFirePath = [[NSBundle mainBundle]pathForResource:@"BabyOnFireParticle" ofType:@"sks"];

    babyFireNode = [NSKeyedUnarchiver unarchiveObjectWithFile:babyFirePath];

    babyFireNode.position = CGPointMake(-30, 40);
    babyFireNode.zPosition = 1;

    [babyNode addChild:babyFireNode];
    }

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    [babyNode removeActionForKey:@"left"];

     babyNode.position = CGPointMake(700, 280);

     moveLeft = [SKAction moveTo:CGPointMake(100, 280)duration:5.0];


    SKAction *completion = [SKAction runBlock:^{

    SKScene *endScene = [[EndScene alloc]initWithSize:self.size];
    SKTransition *doors = [SKTransition crossFadeWithDuration:5];
    [self.view presentScene:endScene transition:doors];

    }];
    SKAction *fire = [self setupbabyFireNode];

    SKAction *sequence = [SKAction sequence:@[ moveLeft ,fire, completion ]];


    SKAction *sequence = [SKAction sequence:@[ moveLeft ,completion ]];

    [babyNode runAction:sequence withKey:@"left"];

    }

1 个答案:

答案 0 :(得分:3)

我想,这就是你要做的事情;

SKAction *sequence = [SKAction sequence:@[moveLeft ,[SKAction performSelector:@selector(spawnPipes) onTarget:self]]];

[Node runAction:sequence];