我设计了一个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];
}
}