ActionsComponent
Hierarchy
- Component
- ActionsComponent
Implements
Index
Constructors
constructor
Returns ActionsComponent
Properties
dependencies
Optionally list any component types this component depends on If the owner entity does not have these components, new components will be added to the entity
Only components with zero-arg constructors are supported as automatic component dependencies
optionalowner
Methods
publicblink
This method will cause an actor to blink (become visible and not visible). Optionally, you may specify the number of blinks. Specify the amount of time the actor should be visible per blink, and the amount of time not visible. This method is part of the actor 'Action' fluent API allowing action chaining.
Parameters
timeVisible: number
The amount of time to stay visible per blink in milliseconds
timeNotVisible: number
The amount of time to stay not visible per blink in milliseconds
optionalnumBlinks: number
The number of times to blink
Returns ActionContext
publiccallMethod
This method allows you to call an arbitrary method as the next action in the action queue. This is useful if you want to execute code in after a specific action, i.e An actor arrives at a destination after traversing a path
Parameters
method: () => any
Returns ActionContext
publicclearActions
Clears all queued actions from the Actor
Returns void
clone
Clones any properties on this component, if that property value has a
clone()
method it will be calledReturns Component
publiccurveBy
Animates an actor with a specified bezier curve by an offset to the current position, the start point is assumed to be the actors current position
Parameters
options: CurveByOptions
Returns ActionContext
publiccurveTo
Animates an actor with a specified bezier curve to an absolute world space coordinate, the start point is assumed to be the actors current position
Parameters
options: CurveToOptions
Returns ActionContext
publicdelay
This method will delay the next action from executing for a certain amount of time (in milliseconds). This method is part of the actor 'Action' fluent API allowing action chaining.
Parameters
duration: number
The amount of time to delay the next action in the queue from executing in milliseconds
Returns ActionContext
publicdie
This method will add an action to the queue that will remove the actor from the scene once it has completed its previous Any actions on the action queue after this action will not be executed.
Returns ActionContext
publiceaseBy
Parameters
offset: Vector
duration: number
optionaleasingFcn: EasingFunction<number>
Returns ActionContext
publiceaseTo
This method will move an actor to the specified
x
andy
position over the specified duration using a given EasingFunctions and return back the actor. This method is part of the actor 'Action' fluent API allowing action chaining.Parameters
pos: Vector
The x,y vector location to move the actor to
duration: number
The time it should take the actor to move to the new location in milliseconds
optionaleasingFcn: EasingFunction<number>
Use EasingFunctions or a custom function to use to calculate position, Default is EasingFunctions.Linear
Returns ActionContext
publicfade
This method will cause an actor's opacity to change from its current value to the provided value by a specified time (in milliseconds). This method is part of the actor 'Action' fluent API allowing action chaining.
Parameters
opacity: number
The ending opacity
duration: number
The time it should take to fade the actor (in milliseconds)
Returns ActionContext
publicflash
This will cause an actor to flash a specific color for a period of time
Parameters
color: Color
duration: number = 1000
The duration in milliseconds
Returns ActionContext
publicfollow
This method will cause the entity to follow another at a specified distance
Parameters
entity: Actor
The entity to follow
optionalfollowDistance: number
The distance to maintain when following, if not specified the actor will follow at the current distance.
Returns ActionContext
publicgetQueue
Returns the internal action queue
Returns ActionQueue
action queue
publicmeet
This method will cause the entity to move towards another until they collide "meet" at a specified speed.
Parameters
entity: Actor
The entity to meet
optionalspeed: number
The speed in pixels per second to move, if not specified it will match the speed of the other actor
Returns ActionContext
publicmoveBy
Moves an actor by a specified offset Vector in a given duration in milliseconds. You may optionally specify an EasingFunction
Parameters
options: MoveByOptions
Returns ActionContext
publicmoveTo
Moves an actor to a specified Vector in a given duration in milliseconds. You may optionally specify an EasingFunction
Parameters
options: MoveToOptions
Returns ActionContext
onAdd
Optional callback called when a component is added to an entity
Parameters
entity: Entity<any>
Returns void
onRemove
Optional callback called when a component is removed from an entity
Returns void
publicrepeat
This method will cause the actor to repeat all of the actions built in the
repeatBuilder
callback. If the number of repeats is not specified it will repeat forever. This method is part of the actor 'Action' fluent API allowing action chaining// Move up in a zig-zag by repeated moveBy's actor.actions.repeat(repeatCtx => { repeatCtx.moveBy(10, 0, 10); repeatCtx.moveBy(0, 10, 10); }, 5);
Parameters
repeatBuilder: (repeatContext: ActionContext) => any
The builder to specify the repeatable list of actions
optionaltimes: number
The number of times to repeat all the previous actions in the action queue. If nothing is specified the actions will repeat forever
Returns ActionContext
publicrepeatForever
This method will cause the actor to repeat all of the actions built in the
repeatBuilder
callback. If the number of repeats is not specified it will repeat forever. This method is part of the actor 'Action' fluent API allowing action chaining// Move up in a zig-zag by repeated moveBy's actor.actions.repeat(repeatCtx => { repeatCtx.moveBy(10, 0, 10); repeatCtx.moveBy(0, 10, 10); }, 5);
Parameters
repeatBuilder: (repeatContext: ActionContext) => any
The builder to specify the repeatable list of actions
Returns ActionContext
publicrotateBy
Rotates an actor by a specified offset angle over a duration in milliseconds, you make pick a rotation strategy RotationType to pick the direction
Parameters
options: RotateByOptions
Returns ActionContext
publicrotateTo
Rotates an actor to a specified angle over a duration in milliseconds, you make pick a rotation strategy RotationType to pick the direction
Parameters
options: RotateToOptions
Returns ActionContext
publicrunAction
Runs a specific action in the action queue
Parameters
action: Action
Returns ActionContext
publicscaleBy
Scales an actor by a specified scale offset Vector over a duration in milliseconds
Parameters
options: ScaleByOptions
Returns ActionContext
publicscaleTo
Scales an actor to a specified scale Vector over a duration
Parameters
options: ScaleToOptions
Returns ActionContext
publictoPromise
Returns a promise that resolves when the current action queue up to now is finished.
Returns Promise<void>
publicupdate
Updates the internal action context, performing action and moving through the internal queue
Parameters
elapsed: number
Returns void
Components are containers for state in Excalibur, the are meant to convey capabilities that an Entity possesses
Implementations of Component must have a zero-arg constructor to support dependencies