Instance Method

updateWithDeltaTime:

Performs periodic updates for each of the entity’s components.

Declaration

- (void)updateWithDeltaTime:(NSTimeInterval)seconds;

Parameters

seconds

The time step to use for any time-dependent actions performed by this method (typically, the elapsed time since the previous call to this method).

Discussion

At runtime, an entity/component-based game needs to dispatch periodic logic—from an update/render loop method such as update: (SpriteKit) or renderer:updateAtTime: (SceneKit), or a CADisplayLink (iOS) or CVDisplayLinkRef (macOS) timer in a custom rendering engine—to each of its components, so that each can perform component-specific update logic.

The GKEntity updateWithDeltaTime: method is one of the two options GameplayKit provides for dispatching updates—this option is easy to implement in games with small numbers of entities and components. Call this method for each entity in your game, and each entity will in turn call the updateWithDeltaTime: method for each of its components.

The other option is to dispatch updates per-component, rather than per-entity, using a GKComponentSystem object. Using a component system allows you to update all components of a specific component class in a deterministic order, without needing to traverse your game’s object graph and update each entity.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software