iosanimationsprite-kitsktexturesktextureatlas

Sprite Kit SKTexture animation height unexpectedly changing


I am using a SKTextureAtlas to animate a SKSpriteNode. The animation works, but it looks weird because for some reason the sprite's height is changing several times in the animation. This also causes the y position to change as well. Everything else remains the same except for the height and the y. The only thing I can think of is there are different amounts of transparent pixels within each frame. Each image is the same size though. Even when I use SKAction.animateWithTextures(atlasFrames, timePerFrame: 0.1, resize: true, restore: false), with resize set to true and false, the problem persists.


Solution

  • I heard about this issue with textures. I recommend you to make all textures of same size and add background for all images of 1% alpha (it wont be visible but it will be where). This is happening because invisible background is cut.

    You can watch this guide for more information: https://www.youtube.com/watch?v=TDwSR3e6nN0