Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UIActor

Helper Actor primitive for drawing UI's, optimized for UI drawing. Does not participate in collisions. Drawn on top of all other actors.

Hierarchy

Implements

Index

Constructors

constructor

Properties

Protected _engine

_engine: Engine

actionQueue

actionQueue: ActionQueue

Direct access to the actor's ActionQueue. Useful if you are building custom actions.

actions

actions: ActionContext

Action context of the actor. Useful for scripting actor behavior.

anchor

anchor: Vector

The anchor to apply all actor related transformations like rotation, translation, and scaling. By default the anchor is in the center of the actor. By default it is set to the center of the actor (.5, .5)

An anchor of (.5, .5) will ensure that drawings are centered.

Use anchor.setTo to set the anchor to a different point using values between 0 and 1. For example, anchoring to the top-left would be Actor.anchor.setTo(0, 0) and top-right would be Actor.anchor.setTo(0, 1).

body

body: Body = new Body(this)

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.

children

children: Actor[] = []

The children of this actor

collisionGroups

collisionGroups: string[] = []

collisionType

collisionType: CollisionType = CollisionType.PreventCollision

Gets or sets the current collision type of this actor. By default it is (CollisionType.PreventCollision).

currentDrawing

currentDrawing: IDrawable = null

Access to the current drawing for the actor, this can be an Animation, Sprite, or Polygon. Set drawings with setDrawing.

enableCapturePointer

enableCapturePointer: boolean = false

Whether or not to enable the CapturePointer trait that propagates pointer events to this actor

eventDispatcher

eventDispatcher: EventDispatcher

Direct access to the game object event dispatcher.

frames

frames: object

Type declaration

id

id: number = ActorImpl.maxId++

The unique identifier for the actor

isOffScreen

isOffScreen: boolean = false

Indicates whether the actor is physically in the viewport

logger

logger: Logger = Logger.getInstance()

Convenience reference to the global logger

oldAcc

oldAcc: Vector = Vector.Zero.clone()

Gets/sets the acceleration of the actor from the last frame. This does not include the global acc Physics.acc.

oldScale

oldScale: Vector = Vector.One.clone()

The scale of the actor last frame

opacity

opacity: number = 1

The opacity of an actor. Passing in a color in the constructor will use the color's opacity.

parent

parent: Actor = null

The parent of this actor

previousOpacity

previousOpacity: number = 1

scale

scale: Vector = Vector.One.clone()

The scale vector of the actor

scene

scene: Scene = null

The scene that the actor is in

sx

sx: number = 0

The x scalar velocity of the actor in scale/second

sy

sy: number = 0

The y scalar velocity of the actor in scale/second

traits

traits: IActorTrait[] = []

Modify the current actor update pipeline.

visible

visible: boolean = true

The visibility of an actor

Static maxId

maxId: number = 0

Indicates the next id to be set

Accessors

acc

  • 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.

    Returns Vector

  • Sets the acceleration vector of teh actor in pixels/second/second

    Parameters

    Returns void

collisionArea

  • Gets the collision area shape to use for collision possible options are [CircleArea|circles], [PolygonArea|polygons], and [EdgeArea|edges].

    Returns ICollisionArea

  • Gets the collision area shape to use for collision possible options are [CircleArea|circles], [PolygonArea|polygons], and [EdgeArea|edges].

    Parameters

    Returns void

color

  • Sets the color of the actor. A rectangle of this color will be drawn if no IDrawable is specified as the actors drawing.

    The default is null which prevents a rectangle from being drawn.

    Returns Color

  • Sets the color of the actor. A rectangle of this color will be drawn if no IDrawable is specified as the actors drawing.

    The default is null which prevents a rectangle from being drawn.

    Parameters

    Returns void

friction

  • get friction(): number
  • set friction(theFriction: number): void
  • Gets the coefficient of friction on this actor, this can be thought of as how sticky or slippery an object is.

    Returns number

  • Sets the coefficient of friction of this actor, this can ve thought of as how stick or slippery an object is.

    Parameters

    • theFriction: number

    Returns void

isGeometryDirty

  • get isGeometryDirty(): boolean
  • Indicates that the actor's collision geometry needs to be recalculated for accurate collisions

    Returns boolean

isInitialized

  • get isInitialized(): boolean
  • Gets wether the actor is Initialized

    Returns boolean

mass

  • get mass(): number
  • set mass(theMass: number): void
  • Get the current mass of the actor, mass can be thought of as the resistance to acceleration.

    Returns number

  • Sets the mass of the actor, mass can be thought of as the resistance to acceleration.

    Parameters

    • theMass: number

    Returns void

moi

  • get moi(): number
  • set moi(theMoi: number): void
  • Gets the current moment of inertia, moi can be thought of as the resistance to rotation.

    Returns number

  • Sets the current moment of inertia, moi can be thought of as the resistance to rotation.

    Parameters

    • theMoi: number

    Returns void

oldPos

  • Gets the position vector of the actor from the last frame

    Returns Vector

  • Sets the position vector of the actor in the last frame

    Parameters

    Returns void

oldVel

  • Gets the velocity vector of the actor from the last frame

    Returns Vector

  • Sets the velocity vector of the actor from the last frame

    Parameters

    Returns void

pos

  • Gets the position vector of the actor in pixels

    Returns Vector

  • Sets the position vector of the actor in pixels

    Parameters

    Returns void

restitution

  • get restitution(): number
  • set restitution(theRestitution: number): void
  • Gets the coefficient of restitution of this actor, represents the amount of energy preserved after collision. Think of this as bounciness.

    Returns number

  • Sets the coefficient of restitution of this actor, represents the amount of energy preserved after collision. Think of this as bounciness.

    Parameters

    • theRestitution: number

    Returns void

rotation

  • get rotation(): number
  • set rotation(theAngle: number): void
  • Gets the rotation of the actor in radians. 1 radian = 180/PI Degrees.

    Returns number

  • Sets the rotation of the actor in radians. 1 radian = 180/PI Degrees.

    Parameters

    • theAngle: number

    Returns void

rx

  • get rx(): number
  • set rx(angularVelocity: number): void
  • Gets the rotational velocity of the actor in radians/second

    Returns number

  • Sets the rotational velocity of the actor in radians/sec

    Parameters

    • angularVelocity: number

    Returns void

torque

  • get torque(): number
  • set torque(theTorque: number): void
  • Gets the current torque applied to the actor. Torque can be thought of as rotational force

    Returns number

  • Sets the current torque applied to the actor. Torque can be thought of as rotational force

    Parameters

    • theTorque: number

    Returns void

vel

  • Gets the velocity vector of the actor in pixels/sec

    Returns Vector

  • Sets the velocity vector of the actor in pixels/sec

    Parameters

    Returns void

x

  • get x(): number
  • set x(theX: number): void
  • Gets the x position of the actor relative to it's parent (if any)

    Returns number

  • Sets the x position of the actor relative to it's parent (if any)

    Parameters

    • theX: number

    Returns void

y

  • get y(): number
  • set y(theY: number): void
  • Gets the y position of the actor relative to it's parent (if any)

    Returns number

  • Sets the y position of the actor relative to it's parent (if any)

    Parameters

    • theY: number

    Returns void

z

  • get z(): number
  • set z(newZ: number): void
  • Returns number

  • Parameters

    • newZ: number

    Returns void

Methods

_initialize

  • _initialize(engine: Engine): void
  • Parameters

    Returns void

_postdraw

  • _postdraw(ctx: CanvasRenderingContext2D, delta: number): void
  • It is not recommended that internal excalibur methods be overriden, do so at your own risk.

    Internal _postdraw handler for onPostDraw lifecycle event

    internal

    Parameters

    • ctx: CanvasRenderingContext2D
    • delta: number

    Returns void

_postkill

  • _postkill(_scene: Scene): void
  • It is not recommended that internal excalibur methods be overriden, do so at your own risk.

    Internal _prekill handler for onPostKill lifecycle event

    internal

    Parameters

    Returns void

_postupdate

  • _postupdate(engine: Engine, delta: number): void
  • It is not recommended that internal excalibur methods be overriden, do so at your own risk.

    Internal _preupdate handler for onPostUpdate lifecycle event

    internal

    Parameters

    • engine: Engine
    • delta: number

    Returns void

_predraw

  • _predraw(ctx: CanvasRenderingContext2D, delta: number): void
  • It is not recommended that internal excalibur methods be overriden, do so at your own risk.

    Internal _predraw handler for onPreDraw lifecycle event

    internal

    Parameters

    • ctx: CanvasRenderingContext2D
    • delta: number

    Returns void

_prekill

  • _prekill(_scene: Scene): void
  • It is not recommended that internal excalibur methods be overriden, do so at your own risk.

    Internal _prekill handler for onPreKill lifecycle event

    internal

    Parameters

    Returns void

_preupdate

  • _preupdate(engine: Engine, delta: number): void
  • It is not recommended that internal excalibur methods be overriden, do so at your own risk.

    Internal _preupdate handler for onPreUpdate lifecycle event

    internal

    Parameters

    • engine: Engine
    • delta: number

    Returns void

Protected _reapplyEffects

  • Parameters

    Returns void

add

  • add(actor: Actor): void
  • Adds a child actor to this actor. All movement of the child actor will be relative to the parent actor. Meaning if the parent moves the child will move with it.

    Parameters

    • actor: Actor

      The child actor to add

    Returns void

addCollisionGroup

  • addCollisionGroup(name: string): void
  • Adds an actor to a collision group. Actors with no named collision groups are considered to be in every collision group.

    Once in a collision group(s) actors will only collide with other actors in that group.

    Parameters

    • name: string

      The name of the collision group

    Returns void

addDrawing

  • addDrawing(texture: Texture): void
  • addDrawing(sprite: Sprite): void
  • addDrawing(key: any, drawing: IDrawable): void
  • Adds a whole texture as the "default" drawing. Set a drawing using setDrawing.

    Parameters

    Returns void

  • Adds a whole sprite as the "default" drawing. Set a drawing using setDrawing.

    Parameters

    Returns void

  • Adds a drawing to the list of available drawings for an actor. Set a drawing using setDrawing.

    Parameters

    Returns void

collides

  • Test whether the actor has collided with another actor, returns the intersection vector on collision. Returns null when there is no collision;

    Parameters

    • actor: Actor

      The other actor to test

    Returns Vector

collidesWithSide

  • Test whether the actor has collided with another actor, returns the side of the current actor that collided.

    Parameters

    • actor: Actor

      The other actor to test

    Returns Side

contains

  • contains(x: number, y: number, useWorld?: boolean): boolean
  • Parameters

    • x: number
    • y: number
    • Default value useWorld: boolean = true

    Returns boolean

debugDraw

  • debugDraw(ctx: CanvasRenderingContext2D): void
  • Called by the Engine, draws the actors debugging to the screen

    Parameters

    • ctx: CanvasRenderingContext2D

      The rendering context

    Returns void

draw

  • draw(ctx: CanvasRenderingContext2D, delta: number): void
  • Called by the Engine, draws the actor to the screen

    Parameters

    • ctx: CanvasRenderingContext2D

      The rendering context

    • delta: number

      The time since the last draw in milliseconds

    Returns void

emit

  • emit(eventName: string, eventObject?: GameEvent<any>): void
  • Emits a new event

    Parameters

    • eventName: string

      Name of the event to emit

    • Optional eventObject: GameEvent<any>

      Data associated with this event

    Returns void

getAncestors

  • getAncestors(): Actor[]
  • Returns the full array of ancestors

    Returns Actor[]

getBottom

  • getBottom(): number
  • Gets the bottom edge of the actor

    Returns number

getBounds

  • Returns the actor's BoundingBox calculated for this instant in world space.

    Parameters

    • Default value rotated: boolean = true

    Returns BoundingBox

getCenter

  • Get the center point of an actor

    Returns Vector

getCollisionHandlers

  • getCollisionHandlers(): object
  • Returns object

    • [key: string]: function[]

getGeometry

  • Returns the actors unrotated geometry in world coordinates

    Returns Vector[]

getGlobalScale

  • Gets the global scale of the Actor

    Returns Vector

getHeight

  • getHeight(): number
  • Gets the calculated height of an actor, factoring in scale

    Returns number

getLeft

  • getLeft(): number
  • Gets the left edge of the actor

    Returns number

getRelativeBounds

  • Returns the actor's BoundingBox relative to the actor's position.

    Parameters

    • Default value rotated: boolean = true

    Returns BoundingBox

getRelativeGeometry

  • getRelativeGeometry(): Vector[]
  • Return the actor's unrotated geometry relative to the actor's position

    Returns Vector[]

getRight

  • getRight(): number
  • Gets the right edge of the actor

    Returns number

getSideFromIntersect

  • Returns the side of the collision based on the intersection

    Parameters

    • intersect: Vector

      The displacement vector returned by a collision

    Returns Side

getTop

  • getTop(): number
  • Gets the top edge of the actor

    Returns number

getWidth

  • getWidth(): number
  • Gets the calculated width of an actor, factoring in scale

    Returns number

getWorldPos

  • Gets an actor's world position taking into account parent relationships, scaling, rotation, and translation

    Returns Vector

    Position in world coordinates

getWorldRotation

  • getWorldRotation(): number
  • Gets this actor's rotation taking into account any parent relationships

    Returns number

    Rotation angle in radians

getZIndex

  • getZIndex(): number
  • 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

    Returns number

integrate

  • integrate(delta: number): void
  • Perform euler integration at the specified time step

    Parameters

    • delta: number

    Returns void

isKilled

  • isKilled(): boolean
  • Indicates wether the actor has been killed.

    Returns boolean

kill

  • kill(): void
  • 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.

    Returns void

off

  • off(eventName: Events.exittrigger, handler?: function): void
  • off(eventName: Events.entertrigger, handler?: function): void
  • off(eventName: Events.collisionstart, handler?: function): void
  • off(eventName: Events.collisionend, handler?: function): void
  • off(eventName: Events.precollision, handler?: function): void
  • off(eventName: Events.postcollision, handler: function): void
  • off(eventName: Events.pointerup, handler?: function): void
  • off(eventName: Events.pointerdown, handler?: function): void
  • off(eventName: Events.pointerenter, handler?: function): void
  • off(eventName: Events.pointerleave, handler?: function): void
  • off(eventName: Events.pointermove, handler?: function): void
  • off(eventName: Events.pointercancel, handler?: function): void
  • off(eventName: Events.pointerwheel, handler?: function): void
  • off(eventName: Events.pointerdragstart, handler?: function): void
  • off(eventName: Events.pointerdragend, handler?: function): void
  • off(eventName: Events.pointerdragenter, handler?: function): void
  • off(eventName: Events.pointerdragleave, handler?: function): void
  • off(eventName: Events.pointerdragmove, handler?: function): void
  • off(eventName: Events.prekill, handler?: function): void
  • off(eventName: Events.postkill, handler?: function): void
  • off(eventName: Events.initialize, handler?: function): void
  • off(eventName: Events.postupdate, handler?: function): void
  • off(eventName: Events.preupdate, handler?: function): void
  • off(eventName: Events.postdraw, handler?: function): void
  • off(eventName: Events.predraw, handler?: function): void
  • off(eventName: string, handler?: function): void
  • Parameters

    Returns void

  • Parameters

    Returns 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.

    Parameters

    Returns 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.

    Parameters

    Returns 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 richochet of the ball depending on which side of the paddle you hit.

    Parameters

    Returns 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.

    Parameters

    Returns void

  • Parameters

    • eventName: Events.pointerup
    • Optional handler: function

    Returns void

  • Parameters

    • eventName: Events.pointerdown
    • Optional handler: function

    Returns void

  • Parameters

    • eventName: Events.pointerenter
    • Optional handler: function

    Returns void

  • Parameters

    • eventName: Events.pointerleave
    • Optional handler: function

    Returns void

  • Parameters

    • eventName: Events.pointermove
    • Optional handler: function

    Returns void

  • Parameters

    • eventName: Events.pointercancel
    • Optional handler: function

    Returns void

  • Parameters

    • eventName: Events.pointerwheel
    • Optional handler: function

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    • eventName: Events.prekill
    • Optional handler: function

    Returns void

  • Parameters

    • eventName: Events.postkill
    • Optional handler: function

    Returns void

  • Parameters

    • eventName: Events.initialize
    • Optional handler: function
        • (event?: Events.InitializeEvent): void
        • Parameters

          • Optional event: Events.InitializeEvent

          Returns void

    Returns void

  • Parameters

    • eventName: Events.postupdate
    • Optional handler: function
        • (event?: Events.PostUpdateEvent): void
        • Parameters

          • Optional event: Events.PostUpdateEvent

          Returns void

    Returns void

  • Parameters

    • eventName: Events.preupdate
    • Optional handler: function
        • (event?: Events.PreUpdateEvent): void
        • Parameters

          • Optional event: Events.PreUpdateEvent

          Returns void

    Returns void

  • Parameters

    • eventName: Events.postdraw
    • Optional handler: function
        • (event?: Events.PostDrawEvent): void
        • Parameters

          • Optional event: Events.PostDrawEvent

          Returns void

    Returns void

  • Parameters

    • eventName: Events.predraw
    • Optional handler: function
        • (event?: Events.PreDrawEvent): void
        • Parameters

          • Optional event: Events.PreDrawEvent

          Returns void

    Returns void

  • Parameters

    • eventName: string
    • Optional handler: function

    Returns void

on

  • on(eventName: Events.exittrigger, handler: function): void
  • on(eventName: Events.entertrigger, handler: function): void
  • on(eventName: Events.collisionstart, handler: function): void
  • on(eventName: Events.collisionend, handler: function): void
  • on(eventName: Events.precollision, handler: function): void
  • on(eventName: Events.postcollision, handler: function): void
  • on(eventName: Events.kill, handler: function): void
  • on(eventName: Events.prekill, handler: function): void
  • on(eventName: Events.postkill, handler: function): void
  • on(eventName: Events.initialize, handler: function): void
  • on(eventName: Events.preupdate, handler: function): void
  • on(eventName: Events.postupdate, handler: function): void
  • on(eventName: Events.predraw, handler: function): void
  • on(eventName: Events.postdraw, handler: function): void
  • on(eventName: Events.predebugdraw, handler: function): void
  • on(eventName: Events.postdebugdraw, handler: function): void
  • on(eventName: Events.pointerup, handler: function): void
  • on(eventName: Events.pointerdown, handler: function): void
  • on(eventName: Events.pointerenter, handler: function): void
  • on(eventName: Events.pointerleave, handler: function): void
  • on(eventName: Events.pointermove, handler: function): void
  • on(eventName: Events.pointercancel, handler: function): void
  • on(eventName: Events.pointerwheel, handler: function): void
  • on(eventName: Events.pointerdragstart, handler: function): void
  • on(eventName: Events.pointerdragend, handler: function): void
  • on(eventName: Events.pointerdragenter, handler: function): void
  • on(eventName: Events.pointerdragleave, handler: function): void
  • on(eventName: Events.pointerdragmove, handler: function): void
  • on(eventName: string, handler: function): void
  • Parameters

    Returns void

  • Parameters

    Returns 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 touched a surface (like landing) or if a item has been touched and needs to be picked up.

    Parameters

    Returns 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.

    Parameters

    Returns 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 richochet of the ball depending on which side of the paddle you hit.

    Parameters

    Returns 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.

    Parameters

    Returns void

  • Parameters

    • eventName: Events.kill
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.prekill
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.postkill
    • handler: function

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    • eventName: Events.predraw
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.postdraw
    • handler: function

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    • eventName: Events.pointerup
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.pointerdown
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.pointerenter
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.pointerleave
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.pointermove
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.pointercancel
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.pointerwheel
    • handler: function

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    • eventName: string
    • handler: function

    Returns void

onCollidesWith

  • onCollidesWith(group: string, func: function): void
  • Register a handler to fire when this actor collides with another in a specified group

    Parameters

    • group: string

      The group name to listen for

    • func: function

      The callback to fire on collision with another actor from the group. The callback is passed the other actor.

        • Parameters

          Returns void

    Returns void

onInitialize

  • onInitialize(_engine: Engine): void
  • 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) => {...})

    Parameters

    Returns void

onPostDraw

  • onPostDraw(_ctx: CanvasRenderingContext2D, _delta: number): void
  • Safe to override onPostDraw lifecycle event handler. Synonymous with .on('postdraw', (evt) =>{...})

    onPostDraw is called directly after an actor is drawn, and before local transforms are removed.

    Parameters

    • _ctx: CanvasRenderingContext2D
    • _delta: number

    Returns void

onPostKill

  • onPostKill(_scene: Scene): void
  • Safe to override onPostKill lifecycle event handler. Synonymous with .on('postkill', (evt) => {...})

    onPostKill is called directly after an actor is killed and remove from its current Scene.

    Parameters

    Returns void

onPostUpdate

  • onPostUpdate(_engine: Engine, _delta: number): void
  • Safe to override onPostUpdate lifecycle event handler. Synonymous with .on('postupdate', (evt) =>{...})

    onPostUpdate is called directly after an actor is updated.

    Parameters

    • _engine: Engine
    • _delta: number

    Returns void

onPreDraw

  • onPreDraw(_ctx: CanvasRenderingContext2D, _delta: number): void
  • Safe to override onPreDraw lifecycle event handler. Synonymous with .on('predraw', (evt) =>{...})

    onPreDraw is called directly before an actor is drawn, but after local transforms are made.

    Parameters

    • _ctx: CanvasRenderingContext2D
    • _delta: number

    Returns void

onPreKill

  • onPreKill(_scene: Scene): void
  • Safe to override onPreKill lifecycle event handler. Synonymous with .on('prekill', (evt) =>{...})

    onPreKill is called directly before an actor is killed and removed from its current Scene.

    Parameters

    Returns void

onPreUpdate

  • onPreUpdate(_engine: Engine, _delta: number): void
  • Safe to override onPreUpdate lifecycle event handler. Synonymous with .on('preupdate', (evt) =>{...})

    onPreUpdate is called directly before an actor is updated.

    Parameters

    • _engine: Engine
    • _delta: number

    Returns void

once

  • once(eventName: Events.exittrigger, handler: function): void
  • once(eventName: Events.entertrigger, handler: function): void
  • once(eventName: Events.collisionstart, handler: function): void
  • once(eventName: Events.collisionend, handler: function): void
  • once(eventName: Events.precollision, handler: function): void
  • once(eventName: Events.postcollision, handler: function): void
  • once(eventName: Events.kill, handler: function): void
  • once(eventName: Events.postkill, handler: function): void
  • once(eventName: Events.prekill, handler: function): void
  • once(eventName: Events.initialize, handler: function): void
  • once(eventName: Events.preupdate, handler: function): void
  • once(eventName: Events.postupdate, handler: function): void
  • once(eventName: Events.predraw, handler: function): void
  • once(eventName: Events.postdraw, handler: function): void
  • once(eventName: Events.predebugdraw, handler: function): void
  • once(eventName: Events.postdebugdraw, handler: function): void
  • once(eventName: Events.pointerup, handler: function): void
  • once(eventName: Events.pointerdown, handler: function): void
  • once(eventName: Events.pointerenter, handler: function): void
  • once(eventName: Events.pointerleave, handler: function): void
  • once(eventName: Events.pointermove, handler: function): void
  • once(eventName: Events.pointercancel, handler: function): void
  • once(eventName: Events.pointerwheel, handler: function): void
  • once(eventName: Events.pointerdragstart, handler: function): void
  • once(eventName: Events.pointerdragend, handler: function): void
  • once(eventName: Events.pointerdragenter, handler: function): void
  • once(eventName: Events.pointerdragleave, handler: function): void
  • once(eventName: Events.pointerdragmove, handler: function): void
  • once(eventName: string, handler: function): void
  • Parameters

    Returns void

  • Parameters

    Returns 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.

    Parameters

    Returns 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.

    Parameters

    Returns 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 richochet of the ball depending on which side of the paddle you hit.

    Parameters

    Returns 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.

    Parameters

    Returns void

  • Parameters

    • eventName: Events.kill
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.postkill
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.prekill
    • handler: function

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    • eventName: Events.predraw
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.postdraw
    • handler: function

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    • eventName: Events.pointerup
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.pointerdown
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.pointerenter
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.pointerleave
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.pointermove
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.pointercancel
    • handler: function

    Returns void

  • Parameters

    • eventName: Events.pointerwheel
    • handler: function

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    Returns void

  • Parameters

    • eventName: string
    • handler: function

    Returns void

remove

  • remove(actor: Actor): void
  • Removes a child actor from this actor.

    Parameters

    • actor: Actor

      The child actor to remove

    Returns void

removeCollidesWith

  • removeCollidesWith(group: string): void
  • Removes all collision handlers for this group on this actor

    Parameters

    • group: string

      Group to remove all handlers for on this actor.

    Returns void

removeCollisionGroup

  • removeCollisionGroup(name: string): void
  • Removes an actor from a collision group.

    Parameters

    • name: string

      The name of the collision group

    Returns void

setDrawing

  • setDrawing(key: string): void
  • setDrawing(key: number): void
  • Sets the current drawing of the actor to the drawing corresponding to the key.

    Parameters

    • key: string

      The key of the drawing

    Returns void

  • Sets the current drawing of the actor to the drawing corresponding to an enum key (e.g. Animations.Left)

    Parameters

    • key: number

      The enum key of the drawing

    Returns void

setHeight

  • setHeight(height: number): void
  • Sets the height of an actor, factoring in the current scale

    Parameters

    • height: number

    Returns void

setWidth

  • setWidth(width: number): void
  • Sets the width of an actor, factoring in the current scale

    Parameters

    • width: number

    Returns void

setZIndex

  • setZIndex(newIndex: number): void
  • 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

    Parameters

    • newIndex: number

      new z-index to assign

    Returns void

unkill

  • unkill(): void
  • If the current actor is killed, it will now not be killed.

    Returns void

update

  • update(engine: Engine, delta: number): void
  • Called by the Engine, updates the state of the actor

    Parameters

    • engine: Engine

      The reference to the current game engine

    • delta: number

      The time elapsed since the last update in milliseconds

    Returns void

within

  • within(actor: Actor, distance: number): boolean
  • Returns true if the two actors are less than or equal to the distance specified from each other

    Parameters

    • actor: Actor

      Actor to test

    • distance: number

      Distance in pixels to test

    Returns boolean

Static extend

  • extend(methods: any): any
  • You may wish to extend native Excalibur functionality in vanilla Javascript. Any method on a class inheriting Class may be extended to support additional functionality. In the example below we create a new type called MyActor.

    var MyActor = Actor.extend({
    
       constructor: function() {
          this.newprop = 'something';
          Actor.apply(this, arguments);
       },
    
       update: function(engine, delta) {
          // Implement custom update
          // Call super constructor update
          Actor.prototype.update.call(this, engine, delta);
    
          console.log("Something cool!");
       }
    });
    
    var myActor = new MyActor(100, 100, 100, 100, Color.Azure);
    

    In TypeScript, you only need to use the extends syntax, you do not need to use this method of extension.

    Parameters

    • methods: any

      A JSON object contain any methods/properties you want to extend

    Returns any

Object literals

capturePointer

capturePointer: object

Configuration for CapturePointer trait

captureDragEvents

captureDragEvents: false = false

captureMoveEvents

captureMoveEvents: false = false

Static defaults

defaults: object

Indicates the next id to be set

anchor

anchor: Vector = Vector.Half.clone()