4

I am using the flowing code to animate my sprite node.

        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]; 

The animation works alright except one image looks bigger and blur. I have 4 images which have size as below:

runnerJumpUp0.png 62*56
runnerJumpUp1.png 62*56
runnerJumpUp2.png 62*56
runnerJumpUp3.png 47*56

The last one's size is different from the other three. When the animation runs, the last image will scale up. The last frame of the sprite will looks bigger than the others. Would you please advise how can I fix that?

Thanks a lot.

Jake

Jake Lin
  • 11,146
  • 6
  • 29
  • 40

1 Answers1

7

Use animateWithTextures:timePerFrame:resize:restore: and set resize to YES.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • 1
    can we apply scale property of sprite on animateWithTexture: or there any other method exist that does the job of animation with Specific ratio? – umer sufyan Jul 18 '14 at 11:30
  • I was about to ask a question about my animation getting scaled down, and this fixed the problem and I'm really grateful for that. Cheers! – HelloimDarius Jan 26 '19 at 16:52