Whether this entity is active, if set to false it will be reclaimed
Observable that keeps track of component add or remove changes on the entity
Direct access to the game object event dispatcher.
The unique identifier for the entity
Convenience reference to the global logger
The scene that the entity is in, if any
Static
defaultsSet defaults for all Actors
Gets the acceleration vector of the actor in pixels/second/second. An acceleration pointing down such as (0, 100) may be useful to simulate a gravitational effect.
Sets the acceleration vector of teh actor in pixels/second/second
Useful for quickly scripting actor behavior, like moving to a place, patrolling back and forth, blinking, etc.
Access to the Actor's built in ActionsComponent which forwards to the Action context of the actor.
Gets the rotational velocity of the actor in radians/second
Sets the rotational velocity of the actor in radians/sec
The physics body the is associated with this actor. The body is the container for all physical properties, like position, velocity, acceleration, mass, inertia, etc.
Access to the Actor's built in ColliderComponent
Access to the Actor's built in GraphicsComponent
Gets whether the actor is Initialized
Indicates whether the actor is physically in the viewport
Access the Actor's built in MotionComponent
Gets the acceleration of the actor from the last frame. This does not include the global acc Physics.acc.
Sets the acceleration of the actor from the last frame. This does not include the global acc Physics.acc.
Access to the Actor's built in PointerComponent config
Gets the rotation of the actor in radians. 1 radian = 180/PI Degrees.
Sets the rotation of the actor in radians. 1 radian = 180/PI Degrees.
Specifically get the tags on the entity from TagComponent
Access the Actor's built in TransformComponent
The types of the components on the Entity
Gets the z-index of an actor. The z-index determines the relative order an actor is drawn in. Actors with a higher z-index are drawn on top of actors with a lower z-index
Sets the z-index of an actor and updates it in the drawing list for the scene. The z-index determines the relative order an actor is drawn in. Actors with a higher z-index are drawn on top of actors with a lower z-index
new z-index to assign
Internal
Initializes this actor and all it's child actors, meant to be called by the Scene before first update not by users of Excalibur.
It is not recommended that internal excalibur methods be overridden, do so at your own risk.
Internal
It is not recommended that internal excalibur methods be overridden, do so at your own risk.
Internal _prekill handler for onPostKill lifecycle event
Internal
It is not recommended that internal excalibur methods be overridden, do so at your own risk.
Internal _preupdate handler for onPostUpdate lifecycle event
Internal
It is not recommended that internal excalibur methods be overridden, do so at your own risk.
Internal _preupdate handler for onPreUpdate lifecycle event
Protected
_setAdds a component to the entity
Component or Entity to add copy of components from
Optionally overwrite any existing components of the same type
Adds a copy of all the components from another template entity as a "prefab"
Entity to use as a template
Force component replacement if it already exists on the target entity
Tests whether the x/y specified are contained in the actor
X coordinate to test (in world coordinates)
Y coordinate to test (in world coordinates)
checks whether the x/y are contained in any child actors (if they exist).
Get a component by type with typecheck
(Does not work on tag components, use .hasTag("mytag") instead)
Check if a component type exists
Unsubscribe an event handler(s) from an event. If a specific handler is specified for an event, only that handler will be unsubscribed. Otherwise all handlers will be unsubscribed for that event.
The name of the event to unsubscribe
Optional
handler: ((event: Events.ExitTriggerEvent) => void)Optionally the specific handler to unsubscribe
Optional
handler: ((event: Events.EnterTriggerEvent) => void)The collisionstart event is fired when a physics body, usually attached to an actor, first starts colliding with another body, and will not fire again while in contact until the the pair separates and collides again. Use cases for the collisionstart event may be detecting when an actor has touch a surface (like landing) or if a item has been touched and needs to be picked up.
Optional
handler: ((event: Events.CollisionStartEvent<Actor>) => void)The collisionend event is fired when two physics bodies are no longer in contact. This event will not fire again until another collision and separation.
Use cases for the collisionend event might be to detect when an actor has left a surface (like jumping) or has left an area.
Optional
handler: ((event: Events.CollisionEndEvent<Actor>) => void)The precollision event is fired every frame where a collision pair is found and two bodies are intersecting.
This event is useful for building in custom collision resolution logic in Passive-Passive or Active-Passive scenarios. For example in a breakout game you may want to tweak the angle of ricochet of the ball depending on which side of the paddle you hit.
Optional
handler: ((event: Events.PreCollisionEvent<Actor>) => void)The postcollision event is fired for every frame where collision resolution was performed. Collision resolution is when two bodies influence each other and cause a response like bouncing off one another. It is only possible to have postcollision event in Active-Active and Active-Fixed type collision pairs.
Post collision would be useful if you need to know that collision resolution is happening or need to tweak the default resolution.
Optional
handler: ((event: PointerEvent) => void)Optional
handler: ((event: PointerEvent) => void)Optional
handler: ((event: PointerEvent) => void)Optional
handler: ((event: PointerEvent) => void)Optional
handler: ((event: PointerEvent) => void)Optional
handler: ((event: PointerEvent) => void)Optional
handler: ((event: WheelEvent) => void)Optional
handler: ((event: PointerEvent) => void)Optional
handler: ((event: PointerEvent) => void)Optional
handler: ((event: PointerEvent) => void)Optional
handler: ((event: PointerEvent) => void)Optional
handler: ((event: PointerEvent) => void)Optional
handler: ((event: Events.PreKillEvent) => void)Optional
handler: ((event: Events.PostKillEvent) => void)Optional
handler: ((event: Events.InitializeEvent<Actor>) => void)Optional
handler: ((event: Events.PostUpdateEvent<Actor>) => void)Optional
handler: ((event: Events.PreUpdateEvent<Actor>) => void)Optional
handler: ((event: Events.EnterViewPortEvent) => void)Optional
handler: ((event: Events.ExitViewPortEvent) => void)Subscribe an event handler to a particular event name, multiple handlers per event name are allowed.
The name of the event to subscribe to
The handler callback to fire on this event
Event signatures
The collisionstart event is fired when a physics body, usually attached to an actor, first starts colliding with another body, and will not fire again while in contact until the the pair separates and collides again. Use cases for the collisionstart event may be detecting when an actor has touched a surface (like landing) or if a item has been touched and needs to be picked up.
The collisionend event is fired when two physics bodies are no longer in contact. This event will not fire again until another collision and separation.
Use cases for the collisionend event might be to detect when an actor has left a surface (like jumping) or has left an area.
The precollision event is fired every frame where a collision pair is found and two bodies are intersecting.
This event is useful for building in custom collision resolution logic in Passive-Passive or Active-Passive scenarios. For example in a breakout game you may want to tweak the angle of ricochet of the ball depending on which side of the paddle you hit.
The postcollision event is fired for every frame where collision resolution was performed. Collision resolution is when two bodies influence each other and cause a response like bouncing off one another. It is only possible to have postcollision event in Active-Active and Active-Fixed type collision pairs.
Post collision would be useful if you need to know that collision resolution is happening or need to tweak the default resolution.
onInitialize
is called before the first update of the actor. This method is meant to be
overridden. This is where initialization of child actors should take place.
Synonymous with the event handler .on('initialize', (evt) => {...})
Once listens to an event once then auto unsubscribes from that event
The name of the event to subscribe to once
The handler of the event that will be auto unsubscribed
The collisionstart event is fired when a physics body, usually attached to an actor, first starts colliding with another body, and will not fire again while in contact until the the pair separates and collides again. Use cases for the collisionstart event may be detecting when an actor has touch a surface (like landing) or if a item has been touched and needs to be picked up.
The collisionend event is fired when two physics bodies are no longer in contact. This event will not fire again until another collision and separation.
Use cases for the collisionend event might be to detect when an actor has left a surface (like jumping) or has left an area.
The precollision event is fired every frame where a collision pair is found and two bodies are intersecting.
This event is useful for building in custom collision resolution logic in Passive-Passive or Active-Passive scenarios. For example in a breakout game you may want to tweak the angle of ricochet of the ball depending on which side of the paddle you hit.
The postcollision event is fired for every frame where collision resolution was performed. Collision resolution is when two bodies influence each other and cause a response like bouncing off one another. It is only possible to have postcollision event in Active-Active and Active-Fixed type collision pairs.
Post collision would be useful if you need to know that collision resolution is happening or need to tweak the default resolution.
Removes a component from the entity, by default removals are deferred to the end of entity update to avoid consistency issues
Components can be force removed with the force
flag, the removal is not deferred and happens immediately
The most important primitive in Excalibur is an
Actor
. Anything that can move on the screen, collide with anotherActor
, respond to events, or interact with the current scene, must be an actor. AnActor
must be part of a Scene for it to be drawn to the screen.