我正在尝试创建一个在淡入时飞到场景中心的盒子,但是 SKAction 似乎从未运行过,有什么想法吗?
-(void)update:(CFTimeInterval)currentTime {
CFTimeInterval delta = currentTime - _previousUpdateTime;
_previousUpdateTime = currentTime;
if (playerLives == 0 && isGameOver == NO) {
[self endGame];
[self moveBallToStartingPosition];
[self displayGameResults];
}
}
....
-(void)displayGameResults {
SKLabelNode *result = [SKLabelNode labelNodeWithFontNamed:@"Helvetica"];
result.color = [UIColor redColor];
result.fontSize = 20;
result.name = @"gameResultsLabel";
result.text = [NSString stringWithFormat:@"Game over! score: %d", playerScore];
SKSpriteNode *container = [SKSpriteNode spriteNodeWithColor:[UIColor redColor] size:[result calculateAccumulatedFrame].size];
container.alpha = 0.3;
container.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMinY(self.frame));
[container addChild:result];
SKAction *moveTo = [SKAction moveTo:CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame)) duration:3.0];
SKAction *fadeIn = [SKAction fadeInWithDuration:3.0];
[container runAction:moveTo];
[container runAction:fadeIn];
[self addChild:container];
}
如果我将它们应用于 SKLabelNode,这些操作也不会运行。
编辑:代码中没有任何删除操作的调用。我不知道为什么他们不开火!