我想将我的SKLabelNode对象向下移动到向上和向下移动

时间:2016-04-21 04:00:49

标签: ios sprite-kit

我设计了一个SKLabelNode对象。每当我触摸SKLabelNode对象时,我想让它从下到上然后上下移动。首先,它将从下往上移动,然后需要从上到下移动。这是代码......任何人都可以提供帮助!

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

    SKNode * helloNode=[self childNodeWithName:@"helloNode"];
    if ([helloNode.name isEqualToString:@"helloNode"])
    {
        helloNode.name = @"";
        SKAction *moveUp = [SKAction moveByX: 0 y: 100.0 duration: 0.5];

        SKAction *pause = [SKAction waitForDuration: 0.5];
        SKAction *fadeAway = [SKAction fadeOutWithDuration: 0.25];
        SKAction *fadeIn = [SKAction fadeInWithDuration:0.25];

        SKAction *moveSequence = [SKAction sequence:@[moveUp, pause, fadeAway,fadeIn]];
        [helloNode runAction: moveSequence];
    }
    else
    {
        helloNode.name=@"helloNode";
        SKAction *moveUp = [SKAction moveByX: 0 y: 50.0 duration: 0.5];
        SKAction *pause = [SKAction waitForDuration: 0.5];
        SKAction *fadeAway = [SKAction fadeOutWithDuration: 0.25];
        SKAction *fadeIn = [SKAction fadeInWithDuration:0.25];


        SKAction *moveSequence = [SKAction sequence:@[moveUp, pause,        fadeAway,fadeIn]];
        [helloNode runAction: moveSequence];

    }
}

0 个答案:

没有答案