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 actor is in
Set defaults for all Actors
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.
Get the center point of an actor (global position)
Get the direct children of this entity
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
Get the local center point of an actor
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
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.
It is not recommended that internal excalibur methods be overridden, do so at your own risk.
Internal _prekill handler for onPostKill lifecycle event
It is not recommended that internal excalibur methods be overridden, do so at your own risk.
Internal _preupdate handler for onPostUpdate lifecycle event
It is not recommended that internal excalibur methods be overridden, do so at your own risk.
Internal _preupdate handler for onPreUpdate lifecycle event
Adds a tag to an entity
Entity
Creates a deep copy of the entity and a copy of all its components
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).
Emits a new event
Name of the event to emit
Data associated with this event
Get a component by type with typecheck
(Does not work on tag components, use .hasTag("mytag") instead)
Returns a list of parent entities starting with the topmost parent. Includes the current entity.
Returns a list of all the entities that descend from this entity. Includes the current entity.
Gets an actor's world position taking into account parent relationships, scaling, rotation, and translation
Position in world coordinates
Gets this actor's rotation taking into account any parent relationships
Rotation angle in radians
Gets the global scale of the Actor
Check if a component type exists
Check if a tag exists on the entity
name to check for
Indicates wether the actor has been killed.
If the current actor is a member of the scene, this will remove it from the scene graph. It will no longer be drawn or updated.
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 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.
Subscribe an event handler to a particular event name, multiple handlers per event name are allowed.
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) => {...})
Safe to override onPostUpdate lifecycle event handler. Synonymous with .on('postupdate', (evt) =>{...})
onPostUpdate
is called directly after an actor is updated.
Safe to override onPreUpdate lifecycle event handler. Synonymous with .on('preupdate', (evt) =>{...})
onPreUpdate
is called directly before an actor is updated.
Once listens to an event once then auto unsubscribes from that event
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 all children from this entity
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
Removes a tag on the entity
Removals are deferred until the end of update
Remove component immediately, no deferred
If the current actor is killed, it will now not be killed.
Unparents this entity, if there is a parent. Otherwise it does nothing.
Called by the Engine, updates the state of the actor
The reference to the current game engine
The time elapsed since the last update in milliseconds
Returns true if the two actor.collider's surfaces are less than or equal to the distance specified from each other
Actor to test
Distance in pixels to test
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.