Create Your First Entity
An entity, as it relates to the Entity-Component architecture, is any game object within your game. This can include things like the player, the monsters, the collectibles, and even the projectiles—but typically, not something like the background.
With GameplayKit, you can either use a generic GKEntity object or create a new GKEntity subclass. For Val’s Revenge, you’ll create a new subclass.
In keeping with your new project organization, create a new group (⌥⌘N) above the Components group and name this new group Entities.
Although the Player class isn’t technically an entity (it’s an SKSpriteNode), drag the Player.swift file into the newly created Entities group. By placing the Player.swift file into the Entities
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access