addComponent(_:)
Adds a component to the entity.
Declaration
func addComponent(_ component: GKComponent)Parameters
- component:
An instance of a Gkcomponent subclass.
Discussion
You create components by subclassing GKEntity to implement reusable behavior. Then, use this method to incorporate the behavior of a component class into that entity.
An entity’s components list never has more than one instance of any component class—if the entity already contains a component of the same class as the component parameter, calling this method will replace that component.