正如你在下面看到的,每当分数增加时,我都会尝试运行一个增加我的 ScoreLabel 大小的操作。当我运行我的应用程序时,我意识到我的标签的大小不会回到原来的形式。我尝试了很多方法,但没有意识到
我希望你能快速回答
-(void)update:(CFTimeInterval)currentTime{
/* Called before each frame is rendered */
// Update wird vor jeden Frame aufgerufen
// Score Counter
if( [speerArray count] > 1) {
SKSpriteNode *sprite = [speerArray objectAtIndex:1];
if (sprite.position.y < superhero.position.y && [sprite.name isEqualToString:@"speer"] && sprite.position.y > 0) {
SKAction* scoreAction = [SKAction scaleBy:2 duration:1];
score ++;
[scoreLabel runAction:scoreAction];
scoreLabel.text = [NSString stringWithFormat:@"%d", score/2];
sprite.name = @"afterBird";
}
}
使用以下行可能是您要查找的内容:
[scoreLabel removeAllActions];
SKAction* scoreAction = [SKAction scaleBy:2 duration:1];
SKAction* revertAction = [SKAction scaleTo:1 duration:1];
SKAction* completeAction = [SKAction sequence:@[scoreAction, revertAction]];
[scoreLabel runAction:completeAction];
如果需要,您也可以执行waitForDuration:
操作。