Instance Method

addComponent:

Adds a component to the entity.

Declaration

- (void)addComponent:(GKComponent *)component;

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.

See Also

Managing an Entity’s List of Components

components

The entity’s list of components.

- componentForClass:

Returns the entity’s component for the specified component class.

- removeComponentForClass:

Removes the component of the specified class from the entity.