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.
Apple wanted to give developers built-in, proprietary graphics rendering infrastructures for even better integration with their own hardware, and that’s where SpriteKit and SceneKit come in. Both frameworks are 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? In this article, we’ll take a quick look at SpriteKit and SceneKit, what they’re best used for, 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.
- Uses Objective-C and Swift
- 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
- Does not require advanced 3D graphical programming skills to use
Dive deeper into SceneKit with Apple’s guide to getting started and SceneKit best practices.
SpriteKit: Best for Simple 2D Animation
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.
Some basics to know:
- 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.
Dive deeper into SpriteKit with Apple’s guide to getting started and SpriteKit best practices.
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.