When designing games, you may need to provide some extra behavior and complexity to sprites and nodes. For example, we may sometimes like to create nodes that consist of several sprites or develop enemies that can behave in one way or another, depending on its type.
For this purpose, one useful solution is to create customized nodes by extending SKNode
in order to inherit all of its properties and utilities and building a complex class to provide the behavior needed for a game.
For the game, we are going to take advantage of this approach to load some enemies. The rabbit's escape route, which is shown in the following screenshot, is a part of the doors, and will be filled by enemies. The enemies will be puppet rabbits, which will move laterally on a rail. These enemies can be of two types. Depending on their type, they will move either from left to right, or from right to left.
Before implementing this solution, let's open the initial project for this chapter, which...