Blurring the edges of an image in SpriteKit

I almost finished my first SpriteKit game. One of the things that worries me is the quality of the images in my application.

Below you can see the difference between the label text and the edges of my logo. The logo is clearly blurred at the edge points. I created the images in Photoshop and they are all PNG. I saved them with or without compression, but no changes. I would like to have sharp edges to make them look good. What should I do?

blurred edge problem

I am using Swift as a language and I read somewhere that the following way of defining an image makes it better, but does not make any difference in my application.

let logoTexture = SKTexture(imageNamed: "img/logo.png")
logo = SKSpriteNode(texture: logoTexture, size: logoTexture.size())

      

+3


source to share


1 answer


I can get the same result if I use 300x150px logo.png. So what you need to do is use the appropriate assets that are @ 2x (and @ 3x if you support iPhone 6+). When you use these naming conventions, iOS will pick the right assets for you. This works with @ 1x and @ 2x, and a bug was found for @ 3x (when using atlases). I'm not sure if it's fixed yet.

You need to make the image 600x300px and name it logo@2x.png . Note that if you simply scale the image in an image editor, you will get the same result, because artifacts always occur when you scale the bitmap. At best, if you have a vector file of your logo, you can scale it up without losing quality. If not, you must make a new high resolution image of the logo.



After making these changes, the content and settings of the simulator will reset and run the application again and it should work.

+3


source







All Articles