This is the third part of An Introduction to GameplayKit. If you haven’t yet gone through the first part and the second part, then I recommend reading those tutorials first before continuing with this one.
Tag Archives: GameplayKit
Alongside all of the new features and frameworks in iOS 9 and OS X El Capitan, with this year’s releases Apple also created an entirely new framework catered to game developers, GameplayKit. With existing graphics APIs (SpriteKit, SceneKit, and Metal) making it easy to create great looking games on iOS and OS X, Apple has now released GameplayKit to make it easy to create games that play well. This new framework contains many classes and functionalities that can be used to easily add complex logic to your games.
In this first tutorial, I will teach you about two major aspects of the GameplayKt framework:
- entities and components
- state machines
This is the second part of An Introduction to GameplayKit. If you haven’t yet gone through the first part, then I recommend reading that tutorial first before continuing with this one.
Let’s look at the most basic way of generating random numbers using GameplayKit, which is the
GKRandomSource class and its
A random source is a provider of an unfiltered stream of random numbers as you need them. As you’ll see soon, GameplayKit has various options for your stream, but for now we’re going to look at the simplest one:
sharedRandom() for a random number source returns the systems built-in random source that’s used for a variety of other tasks, which means you can be pretty sure it’s in a truly random state by the time it gets to you. It does, however, mean that it’s useless for synchronizing network games, because everyone’s device is in a different state.