Build a Monster Generator
The monster generator is what you’ll use to periodically spawn new monsters of a certain type at specific locations within the dungeon.
In the Project Navigator, select the Components group, and inside that group, create a new file (⌘N) using the iOS Swift File template. Name the new file GeneratorComponent.swift and replace its contents with the following code:
| import SpriteKit |
| import GameplayKit |
| |
| class GeneratorComponent: GKComponent { |
| |
| override func didAddToEntity() { |
| |
| } |
| |
| override class var supportsSecureCoding: Bool { |
| true |
| } |
| } |
Because you won’t be overriding any of the other standard methods in this component, you can omit them.
Also, because you’ll be doing a lot ...
Get Apple Game Frameworks and Technologies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.