Search code examples
iosswiftsprite-kitskspritenode

Can anyone explain why to we need to scale in SpriteKit?


I'm trying to learn how to develop IOS games, and i just can't get it why do i see in most of the tutorials setScale(0.5) for an SKSpriteNode, mostly for the ground and stuff like that.

But i don't understand why is that scaling, why not make the size what i want in the first place and not scale down? And how that affects per devices? I see that a lot but can't figure that out.

Thank you, Erez


Solution

  • Scale is useful for several things. The simple case would be you need a different size of an existing asset. For example say you need thumbnails of an existing asset. You can scale it down instead of having a smaller version of that asset. In general you want to scale down versus scale up. But scaling up can work at certain times.

    Now a more complicated case. Animation or special effects. While most people probably use flip book style animations, mixing this with scale can have benefits. Take a bouncing ball. When a ball bounces, it compresses (scale Y). You can either represent this as artwork, or you can use scale. You could also have an enemy "jump out" from an area. You may do this by having him very small and behind a bush. As he is "jumping out" you are scaling him up to 100% (or maybe even more).

    These are just a few examples of the usefulness of scale.