如何在iOS7 SpriteKit中为不同大小的图像制作动画?

Jak*_*Lin 3 ios7 sprite-kit skspritenode sktexture

我正在使用流动的代码来动画我的精灵节点.

        NSMutableArray *jumpUpTextures = [NSMutableArray arrayWithCapacity:10];
        for (int i = 0; i < 4; i++) {
            NSString *textureName = [NSString stringWithFormat:@"runnerJumpUp%d", i];
            SKTexture *texture = [SKTexture textureWithImageNamed:textureName];
            [jumpUpTextures addObject:texture];
        }

        SKAction *jumpUpAnimation = [SKAction animateWithTextures:jumpUpTextures timePerFrame:0.2]; 
Run Code Online (Sandbox Code Playgroud)

除了一个图像看起来更大和模糊之外,动画效果还可以.我有4张图片,大小如下:

runnerJumpUp0.png 62*56
runnerJumpUp1.png 62*56
runnerJumpUp2.png 62*56
runnerJumpUp3.png 47*56
Run Code Online (Sandbox Code Playgroud)

最后一个的大小与其他三个不同.动画运行时,最后一个图像将向上扩展.精灵的最后一帧看起来比其他帧大.你能告诉我该如何解决这个问题?

非常感谢.

可靠的人

Lea*_*s2D 6

使用animateWithTextures:timePerFrame:resize:restore:并将resize设置为YES.