Simplifying iOS Game Logic with GameplayKit’s Rule Systems
When you develop a game, you need sprinkle conditionals everywhere. If Pac-Man has just eaten a power pill, then ghosts should run away. If the player has low health, then attack more aggressively. If the space invader hits the left edge, then it should start moving right. Usually, these bits of code are strewn around, embedded in larger functions, and the overall logic of the game is hard to see or reuse to build up new levels.
There’s no need to bust out a physics textbook to make your iOS 7 app’s views animate like real-world objects. With iOS 7’s new Dynamics API, views can be influenced by gravity, attached to each other with springs, and bounced up against boundaries and each other.