Class: AnimateSystem

Animation system. Updates entity positions each timestep via very generic time based callback functions.

Hierarchy

Constructors

constructor

new AnimateSystem(): AnimateSystem

Returns

AnimateSystem

Overrides

System.constructor

Properties

aspects

Protected aspects: Map<string, Animatable>

Inherited from

System.aspects


name

Readonly name: string

Name of the system for debugging purposes.

Inherited from

System.name

Methods

beginFrame

beginFrame(dt, engine, steps): void

Overridable method called in the beginning of each frame.

Parameters

Name Type Description
dt number Time elapsed since last frame
engine Engine Engine instance
steps number Total number of steps for this frame

Returns

void

Inherited from

System.beginFrame


destroy

destroy(): void

Overridable method called when the engine is destroyed. Call super to clear the protected aspects map.

Returns

void

Inherited from

System.destroy


endFrame

endFrame(dt, engine, steps): void

Overridable method called in the end of each frame.

Parameters

Name Type Description
dt number Time elapsed since last frame
engine Engine Engine instance
steps number Total number of steps for this frame

Returns

void

Inherited from

System.endFrame


getAspect

getAspect<T>(type, entity): undefined | T

Get typed aspect bound to the entity. If the entity has an aspect in the system but it is not of the specified type the return value will be undefined.

Type parameters

Name Type
T extends Animatable

Parameters

Name Type Description
type Type<T> Type of the aspect
entity string Entity to get the aspect from

Returns

undefined | T

Inherited from

System.getAspect

getAspect(entity): undefined | Animatable

Get the aspect bound to the entity.

Parameters

Name Type Description
entity string Entity to get the aspect from

Returns

undefined | Animatable

Inherited from

System.getAspect


getAspects

getAspects(): Map<string, Animatable>

Get access to the aspect map for iterating entities.

Do not modify the returned map directly!

Always use setAspect and removeAspect to modify the aspect map to ensure that the overloaded versions of these functions are called properly. Same warning applies for direct access to the protected this.aspects in the derived sub-systems.

Returns

Map<string, Animatable>

Inherited from

System.getAspects


getEntities

getEntities(): string[]

Get a list of all entities that have aspects in this system.

Returns

string[]

Deprecated

This is a very unoptimal way to access the aspects. You should use getAspects (or this.aspects inside System scope) to access the entities.

Inherited from

System.getEntities


removeAspect

removeAspect(entity): void

Remove the aspect bound to the entity.

Parameters

Name Type Description
entity string Entity to remove the aspect from

Returns

void

Inherited from

System.removeAspect


requireAspect

requireAspect<T>(type, entity): T

Get typed aspect bound to the entity. If the aspect is not found or if the entity has an aspect in the system but it is not of the specified type an exception is thrown.

Type parameters

Name Type
T extends Animatable

Parameters

Name Type Description
type Type<T> Type of the aspect
entity string Entity to get the aspect from

Returns

T

Inherited from

System.requireAspect

requireAspect(entity): Animatable

Get the aspect bound to the entity. If the aspect is not found an exception is thrown.

Parameters

Name Type Description
entity string Entity to get the aspect from

Returns

Animatable

Inherited from

System.requireAspect


setAspect

setAspect(entity, aspect): void

Set the entity’s aspect in this sub-system. Usually the aspect is created with new AspectT(...) and then passed to setAspect.

Parameters

Name Type Description
entity string Entity to set the aspect for
aspect Animatable The aspect to set

Returns

void

Inherited from

System.setAspect


step

step(dt, engine): void

Overridable method called n times each frame depending on how much time has elapsed since the last frame.

Parameters

Name Type Description
dt number The fixed time step
engine Engine Engine instance

Returns

void

Overrides

System.step