Pixel Art Sprites in SpriteKit

For Mountain Dash I decided to adopt a pixel art aesthetic, primarily as a way to keep the design of the graphics simple, but this choice has lead to its own challenges. I decided I would use a 16 x 32 pixel sprite but that I would render it at 32 x 64 points. Initially I was exporting my assets at 64 x 128 pixels for @2x and 96 x 192 pixels for @3x, but I figured that this was wasteful and there had to be a better way. So I decided to use only a 16 x 32 pixel image at 1x and scale the sprite to 32 x 64 points.

The following is what I got on my first attempt:

Blurry Sprite

The sprite is blurry because of how it is scaled up. Fortunately, this is a simple 1-liner to fix. All you need to do is set filteringMode on your textures (all of them) to .nearest.

let firstTexture = climberAtlas.textureNamed("climber_still")
firstTexture.filteringMode = .nearest
climber = SKSpriteNode(texture: firstTexture)

…and voilà the sprite is rendered pixel perfect as desired!

Sharp Sprite

Mountain Dash – a game

Mountain Dash App Icon

In January I decided to try and write my first iOS game. Inspired by our new home in Switzerland and the movie North Face, I decided that it would be a mountain climbing game. To keep things as simple as possible, it will be written in Swift using SpriteKit. Graphics will be done in a pixel art style. My son will be helping me with art and game play ideas.

Mountain Dash edelweiss

Why a game? Because I’ve always loved (retro) games, and I want to challenge myself with something new and learn frameworks and tools that I’ve never had occasion to use. Initially I thought I would open source the game (indeed it was a public repo on GitHub until just recently), but I finally decided against that for now. Mostly because even if the game is destined to never earn a penny, it would still suck if someone copied it, cloned it, and submitted it to the App Store before me. Maybe I’ll consider open-sourcing it after the game is finished. Regardless, I hope to write about little development challenges I run into along the way. Indeed I am already behind in writing about the first of those.

I’ve also invited my friend and colleague, Ethan Mateja, to join me in working on the game. I enjoy working with him and I hope that between the two of us we can keep things moving forward and not let the project languish. To be honest I didn’t touch the game during the entire month of February. But it’s March now and I’m pushing forward again.