What is SpriteKit?
When it comes to developing games to run on mobile devices, graphics APIs like OpenGL and Apple’s own Metal have become the gold standard. These APIs connect mobile device hardware like GPUs to software, handling more resource-heavy graphics rendering to bring complex games and animations to life. However, there’s more to a full graphics software stack. To take full advantage of the power of an API, developers require a graphics rendering engine on top, sandwiched between it and the application framework.
SpriteKit is a framework designed for 2D animations on a simpler scale—think lower-level 2D animations in more efficient apps that don’t require a lot of battery power to run, like Candy Crush or Angry Birds. SpriteKit came along after SceneKit (released with iOS 7), giving developers all the tools they needed to build 2D animated, sprite-based games from scratch without requiring the OpenGL graphics API.
For the non-developer, sprites are a single file that contains all of the graphics for an entire webpage or game, from which individual graphics are then pulled. A sprite is downloaded once and smaller graphics are placed on-screen based on coordinates. This essentially means an app doesn’t have to make numerous, time- and resource-consuming calls to a server for imagery and animations, it just accesses the sprite—and in turn, SpriteKit handles any rendering with a traditional rendering loop.
SpriteKit vs. SceneKit
SpriteKit and SceneKit are frameworks used for adding animation to iOS apps and games, along with the Core Animation framework, QuartzCore and GLKit, a precursor to SceneKit and SpriteKit. Both are suited for varying degrees of complexity when it comes to adding animation to an app, so how are these two frameworks different, and which is best for your project?
SceneKit: 3D scenes & game animation
SceneKit is the more high-performance option of the two, based on the Core Animation framework—and it requires a good bit of math and geometry to use. Think: 3D games that have multiple camera angles, like Fruit Ninja. It’s a high-level 3D graphics framework used to create animated scenes with a rendering engine and a descriptive API, which does a little more legwork for you than lower-level APIs like Metal.
SceneKit was released with the Lion OS and was designed to make it easier for developers to create complex 3D scenes because it “only requires descriptions of your scene’s contents and the actions or animations you want it to perform.” Its hierarchical “scene graph” allows it to perform animations before they’re rendered by a device’s GPU, making it more efficient.
- It uses Objective-C and Swift
- It can be accessed via Swift Playgrounds
- SceneKit works alongside technologies like Quartz, Core Animation, and GL Kit and integrates with other graphics technologies to get a wide range of results
- It does not require advanced 3D graphical programming skills to use
- SpriteKit also provides functionality to games like basic sound playback support and physics simulation, cropping, forces, collisions, and other special effects. It shouldn’t be limited to just gaming apps, however—it’s excellent for adding engaging motion and effects to any content.
- Xcode provides built-in support for SpriteKit—and both of these tools together create a powerful platform for creating complex special effects for games or apps.
- It uses the Swift programming language
- It’s easy for first-times to work with
- Support for Metal and OpenGL graphics APIs
- It’s available on both iOS and OS X, and it’s relatively easy to port code between the two.
Key takeaway: SpriteKit lets developers focus on more important, high-level design and gameplay aspects, not lower-level work like submitting drawing commands to the API.
SpriteKit & SceneKit together
It’s important to note that the two frameworks can be used together, as well. A 2D SpriteKit scene can be layered over a 3D SceneKit scene, or it can be added as a background, foreground overlay, or object texture. No matter what framework you’re using for animation, be sure you’re well-versed in Apple’s Visual Design animation standards.