April 2021
Beginner to intermediate
506 pages
11h 57m
English
Rather than use the same agent component for the player that you’re using for the monsters, you’ll add an agent property directly to the Player class.
Switch to Player.swift file and add a new property, placing it directly above the currentDirection property:
| | var agent = GKAgent2D() |
Next, inside the init(coder:) method, and at the end of that method, set the delegate for your new agent:
| | agent.delegate = self |
Because you created an SKNode extension to handle the agent delegate methods, you’re able to set the Player class as the delegate without having to add those methods here. Remember, the Player class is a subclass of the SKSpriteNode class, which, itself, is a subclass of the SKNode class.
All right, switch ...
Read now
Unlock full access