How can i model Entities and Components in a effective way in GameplayKit/SpriteKit

Viewed 1294

Starting with GameplayKit here, I'm modelling an endless runner where the player can swap between characters with a click on screen. The character first can attack in short range (component), the second jumps (component), and the third shoots (component).

I would like to know what would be the best way for modelling between those two:

  1. Create a class Player that has 3 different characters entities (array), which one with it's components

  2. Create an entity Player that has 3 different characters components and add all movement and actions components (shoot/jumping...)

It's a real big project so i'm worried about the the best way to keep the code mantainable and readable for a long life-time.

Ps:. The SpriteComponent will be the component responsible visual representation on .sks for all entities.

Ps2:. Examples in swift if possible.

Thank you for your time.

1 Answers
Related