Guides and Sample Code

Developer

GameplayKit Programming Guide

On This Page

About GameplayKit

GameplayKit is a collection of foundational tools and technologies for building games in iOS, OS X, and tvOS. Building, evolving, and maintaining a sophisticated game requires a well-planned design—GameplayKit provides architectural tools to help you design modular, scalable game architecture with minimal effort. Creating great games also requires deploying complex algorithms to solve the problems underlying common game mechanics—GameplayKit also provides standard implementations of such algorithms, allowing you to spend more time on the features that make your gameplay unique.

Because GameplayKit is independent of high-level game engine technologies, you can combine it with any of those technologies to build a complete game: SpriteKit for 2D games, SceneKit for 3D games, or a custom or third-party game engine using Metal or OpenGL ES. For games with less demanding graphics needs, you can even use GameplayKit with UIKit (in iOS or tvOS) or AppKit (in OS X).

GameplayKit provides seven core areas of functionality, which you can combine or use independently to create your game:

image: ../Art/icon_random_2x.png

Randomization. Use these robust, flexible implementations of standard algorithms as the building blocks for many kinds of game mechanics.

image: ../Art/icon_entities_2x.png

Entities and Components. Design more reusable gameplay code by building on this architecture.

image: ../Art/icon_state_machines.pdf

State Machines. Use this architecture to untangle complex procedural code in your gameplay designs.

image: ../Art/icon_min_max.pdf

The Minmax Strategist. Create a model for your turn-based game and AI player objects that use the model to plan optimal moves.

image: ../Art/icon_path_finding.pdf

Pathfinding. Describe a game world as a graph, allowing GameplayKit to plan optimal routes for game characters to follow.

image: ../Art/icon_agents.pdf

Agents, Goals, and Behaviors. Use this simulation to let game characters move themselves based on high-level goals and react to their surroundings.

image: ../Art/icon_rule.pdf

Rule Systems. Separate game design from executable code to speed up your gameplay development cycle, or implement fuzzy logic reasoning to add realistic behavior to your game.

Examples

The example games discussed in this book are available as sample code, so you can download each as a complete project to see GameplayKit (and other technologies) in action:

See Also

The example games in this guide are built with the UIKit, SpriteKit, and SceneKit frameworks. Before using GameplayKit in concert with one of these technologies, you should be familiar with the relevant concepts and tools, and generally familiar with building apps for Apple platforms. See the following documents for more information about whichever game engine technology you plan to work with: