Infinite Loop —

OS X 10.9 Mavericks: The Ars Technica Review

No longer an apex predator, OS X takes some time for introspection.

Sprite Kit

Last year, Apple introduced Scene Kit, an OS X framework that did for 3D what Core Animation did for 2D animation: made it accessible to programmers who would otherwise run screaming from any mention of OpenGL or GPU-accelerated drawing code.

Despite my enthusiasm for Scene Kit, it hasn’t exactly set the Mac development world on fire in the short year since its introduction. Off the top of my head, I can think of only one prominent Mac application that has integrated Scene Kit: Delicious Library 3.

Delicious Library 3 uses Scene Kit to render three-dimensional items on its virtual shelves. Even the highlight is 3D.

I think its use of 3D to give some extra heft and sparkle to shelved items is extremely restrained and tasteful, but I’ve also heard the opposite opinion expressed. Perhaps 3D models are more polarizing than 2D animations.

While it’s possible to write a 3D game using Scene Kit, that isn’t the goal of the framework. It’s meant to help developers of regular Mac applications integrate 3D models and effects. Whether or not you believe that’s a good idea, I think Delicious Library 3 proves that Scene Kit has achieved its goal.

Mavericks includes a framework that’s clearly part of the same family tree: Sprite Kit. I’m not sure which project was started first within Apple, but I did notice that Sprite Kit got the “SK” class name prefix while Scene Kit was stuck with “SCN.”

A sprite is a 2D image that can be placed and manipulated independently in a larger scene. If you’ve ever played a game on the original Nintendo Entertainment System, you’ve seen sprites in action. All the player characters, items, and enemies moving around the screen are sprites.

Sprite Kit—you guessed it—makes it easy for Mac developers to integrate 2D sprites into their applications. But wait, doesn’t Core Animation already cover the same territory? Not quite. While Core Animation and Scene Kit are both aimed at normal applications, Sprite Kit is explicitly designed for games.

Games have very different requirements than normal applications. While an application might have an animation to punctuate a particular transition, games are running animations constantly. Games are also likely to have many more animated elements on the screen simultaneously. And unlike a sheet that slides down or a dialog box that fades in and out, animated elements in games are expected to interact with each other.

Sprite Kit provides a complete set of tools for building a 2D game. It has a physics engine with collision detection to handle sprite interactions. Sprites can be scaled and distorted, and they can have Core Image filters and particle effects applied to them.

There’s a ray casting system for game mechanics based on line-of-sight, and methods for drawing vector shapes and text into a scene. Sprite Kit can even turn video into a sprite, with all the same effects, transformations, and physics as a normal sprite. All of this functionality is provided through a pleasantly abstracted Objective-C API that’s a far cry from the typical low-level C/C++ game engine code.

Recognizing that writing code is only a small part of game development, Apple has taken the extra step of adding Sprite-Kit-specific features to its Xcode IDE. Xcode will automatically combine individual sprite image files into larger, more efficient texture atlases. An integrated particle editor makes creating and adjusting particle effects a fun, visual experience instead of a frustrating exercise of adjusting parameters and recompiling.

Sprite Kit particle emitters can be created and edited right in Xcode using this real-time visual interface.

Finally, in case it doesn’t go without saying, Sprite Kit works on both OS X and iOS. Not even Apple is foolish enough to create a framework this extensive for the sole purpose of creating 2D games for the Mac.

Seasoned game developers may turn up their noses at the build-your-own-2D-game toolkit Apple has provided in Sprite Kit. Perhaps they’ve already got their own sprite engines written in C or C++ and their own asset pipelines that are part of a larger multi-platform game development effort.

But for a small team that wants to make a great iOS game first and foremost, Sprite Kit gives them a huge leg up. As a bonus, if they code carefully, they’ll get a Mac version of the same game almost for free.

And for any of those aforementioned seasoned game developers who happen to have an Apple developer account, I dare you to watch WWDC session 502, Introduction to Sprite Kit, and not come away at least slightly impressed by how easy Apple has made it to create a high-quality Mac and iOS sprite-based game.

Scene Kit was the biggest surprise of last year’s WWDC for me—a fun, impressive framework that no one saw coming. Sprite Kit was a bit more predictable, but no less impressive. I hope it’s more widely adopted than its slightly older cousin.

John Siracusa
John Siracusa has a B.S. in Computer Engineering from Boston University. He has been a Mac user since 1984, a Unix geek since 1993, and is a professional web developer and freelance technology writer. Emailsiracusa@arstechnica.com//Twitter@siracusa