【问题标题】:SpriteKit scaleTo action scaling issueSpriteKit scaleTo 动作缩放问题
【发布时间】:2014-08-29 14:46:03
【问题描述】:

我正在尝试将一个节点缩小到一个小尺寸,向下移动,然后在所有这些发生后重复地对其进行动画处理(在相同的缩小尺寸下使用不同的纹理)。

这是我缩小节点并移动它的方法。那部分工作正常。但是,一旦完成,我需要更改精灵纹理并为其设置动画。

- (void)shrinkAndMoveToPosition:(CGPoint)position {

    SKAction *move = [SKAction moveTo:position duration:.5];
    SKAction *scale = [SKAction scaleTo:.3 duration:.5];
    SKAction *moveAndScale = [SKAction group:@[move, scale]];
    [self runAction:moveAndScale completion:^{

        NSArray *textures = @[[SKTexture textureWithImageNamed:@"ship-small_01"],
                              [SKTexture textureWithImageNamed:@"ship-small_02"],
                              [SKTexture textureWithImageNamed:@"ship-small_03"],
                              [SKTexture textureWithImageNamed:@"ship-small_04"]];

        SKAction *animate = [SKAction animateWithTextures:textures timePerFrame:0.5];

        [self runAction:[SKAction repeatActionForever:animate]];

    }];


}

问题是每当我的完成块运行时,精灵都会跳回到纹理的大小。如何保持缩小后的尺寸?

【问题讨论】:

  • 尝试将最后一行切换到 SKAction *repeatAnimation = [SKAction repeatActionForever:animate];
  • @RachelGallen 那么什么会执行该操作?如果我用你的建议替换它,动画动作将永远不会运行
  • 我不认为这是精灵改变比例,只是你正在使用尚未缩放的纹理制作动画。 我认为

标签: ios ios7 sprite-kit scale


【解决方案1】:

我只需要调用一个不同的 animate 方法并将 YES 传递给 resize 参数:

SKAction *animate = [SKAction animateWithTextures:textures timePerFrame:0.5 resize:YES restore:NO];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-06-19
    • 2013-10-05
    • 2014-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多