Drakalex
Drakalex

Reputation: 1538

How to avoid the smooth effect in SpriteKit?

I'm working with very small sprites, in order to create a retro game with pixellated sprites. But when I change the scale of my sprites to make them bigger, Sprite Kit smoothes the sprites and thats not what I want.

Is there any way to keep a sprite pixellated when I increase its scale ?

Upvotes: 4

Views: 178

Answers (2)

Whirlwind
Whirlwind

Reputation: 13665

You could play with texture filtering mode .Nearest (default is .Linear). Texture filtering modes can be used when the texture is drawn in a size other than its native size.

SKTextureFilteringNearest

Each pixel is drawn using the nearest point in the texture. This mode is faster, but the results are often pixelated.

Try and see where it will get you.

But you should keep in mind that some artefacts will always occur when scaling a bitmap (especially if you use filtering mode .Nearest)

Upvotes: 3

Luca Angeletti
Luca Angeletti

Reputation: 59506

Instead of increasing the size of your sprites via code, you should provide bigger images. This way the definition of the textures will be preserved.

If you still need to change the size of a sprite during the gameplay you can always reduce them.

Upvotes: 2

Related Questions