Skip to main content

GpuParticleEmitter

The most important primitive in Excalibur is an Actor. Anything that can move on the screen, collide with another Actor, respond to events, or interact with the current scene, must be an actor. An Actor must be part of a Scene for it to be drawn to the screen.

Hierarchy

Index

Constructors

constructor

Properties

publicactions

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.

publicbody

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.

publicchildrenAdded$

childrenAdded$: Observable<Entity<any>> = ...

publicchildrenRemoved$

childrenRemoved$: Observable<Entity<any>> = ...

publiccollider

Access to the Actor's built in ColliderComponent

publiccomponentAdded$

componentAdded$: Observable<Component> = ...

publiccomponentRemoved$

componentRemoved$: Observable<Component> = ...

publiccomponentValues

componentValues: Component[] = []

publicreadonlycomponents

components: Map<Function, Component> = ...

Current components on the entity

Do not modify

Use addComponent/removeComponent otherwise the ECS will not be notified of changes.

publicemitRate

emitRate: number = 1

publicemitterType

emitterType: EmitterType = EmitterType.Rectangle

publicevents

events: EventEmitter<ActorEvents> = ...

Listen to or emit events for an entity

publicgraphics

graphics: GraphicsComponent = ...

Access to the Actor's built in GraphicsComponent

publicid

id: number = ...

The unique identifier for the entity

publicisActive

isActive: boolean = true

Whether this entity is active, if set to false it will be reclaimed

publicisEmitting

isEmitting: boolean = false

publiclogger

logger: Logger = ...

Convenience reference to the global logger

publicreadonlymaxParticles

maxParticles: number = 2000

publicmotion

Access the Actor's built in MotionComponent

publicname

name: string = ...

publicparticle

particle: GpuParticleConfig = ...

publicpointer

Access to the Actor's built in PointerComponent config

publicradius

radius: number = 0

random

random: Random

publicrenderer

publicscene

scene: Scene<unknown> = null

The current scene that the entity is in, if any

publictagAdded$

tagAdded$: Observable<string> = ...

publictagRemoved$

tagRemoved$: Observable<string> = ...

publictransform

Access the Actor's built in TransformComponent

publicstaticdefaults

defaults: { anchor: Vector } = ...

Set defaults for all Actors


Type declaration

Accessors

publicacc

  • 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

publicactive

  • get active(): boolean
  • set active(val: boolean): void
  • Whether this entity is active, if set to false it will be reclaimed

    @deprecated

    use isActive


    Returns boolean

  • Whether this entity is active, if set to false it will be reclaimed

    @deprecated

    use isActive


    Parameters

    • val: boolean

    Returns void

publicanchor

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


    Returns Vector

  • Parameters

    Returns void

publicangularVelocity

  • get angularVelocity(): number
  • set angularVelocity(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

publiccenter

  • Get the center point of an actor (global position)


    Returns Vector

publicchildren

  • get children(): readonly Entity<any>[]
  • Get the direct children of this entity


    Returns readonly Entity<any>[]

publiccolor

  • Sets the color of the actor's current graphic


    Returns Color

  • Parameters

    Returns void

publicdraggable

  • get draggable(): boolean
  • set draggable(isDraggable: boolean): void
  • Returns boolean

  • Parameters

    • isDraggable: boolean

    Returns void

publicglobalPos

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


    Returns Vector

publicglobalRotation

  • get globalRotation(): number
  • The actor's rotation (in radians) taking into account any parent relationships


    Returns number

publicglobalScale

  • The global scale of the Actor


    Returns Vector

publicglobalZ

  • get globalZ(): number
  • The global z-index of the actor


    Returns number

publicheight

  • get height(): number
  • Returns number

publicisAdded

  • get isAdded(): boolean
  • Returns boolean

publicisInitialized

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


    Returns boolean

publicisOffScreen

  • get isOffScreen(): boolean
  • Indicates whether the actor is physically in the viewport


    Returns boolean

publiclocalCenter

  • Get the local center point of an actor


    Returns Vector

publicoffset

  • The offset in pixels to apply to all actor graphics

    Default offset of (0, 0)


    Returns Vector

  • Parameters

    Returns void

publicoldAcc

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


    Returns Vector

  • Sets the acceleration of the actor from the last frame. This does not include the global acc Physics.acc.


    Parameters

    Returns void

publicoldGlobalPos

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


    Returns Vector

publicoldPos

  • 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

publicoldVel

  • 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

publicparent

  • Returns Entity<any>

publicpos

  • Gets the position vector of the actor in pixels


    Returns Vector

  • Sets the position vector of the actor in pixels


    Parameters

    Returns void

publicrotation

  • 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

publicscale

  • Returns Vector

  • Parameters

    Returns void

publictags

  • get tags(): Set<string>
  • Specifically get the tags on the entity from TagsComponent


    Returns Set<string>

publictypes

  • The types of the components on the Entity


    Returns ComponentCtor[]

publicvel

  • 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

publicwidth

  • get width(): number
  • Returns number

publicz

  • get z(): number
  • set z(z: number): void
  • 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

  • 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

    • z: number

      new z-index to assign

    Returns void

Methods

public_initialize

  • _initialize(engine: Engine<any>): void
  • Parameters

    Returns void

publicaddChild

  • Adds an entity to be a child of this entity


    Parameters

    Returns Entity<any>

publicaddComponent

  • addComponent<TComponent>(component: TComponent, force?: boolean): Entity<any>
  • Adds a component to the entity


    Type parameters

    Parameters

    • component: TComponent

      Component or Entity to add copy of components from

    • force: boolean = false

      Optionally overwrite any existing components of the same type

    Returns Entity<any>

publicaddTag

  • addTag(tag: string): Entity<any>
  • Adds a tag to an entity


    Parameters

    • tag: string

    Returns Entity<any>

publicaddTemplate

  • addTemplate(templateEntity: Entity<any>, force?: boolean): Entity<any>
  • Adds a copy of all the components from another template entity as a "prefab"


    Parameters

    • templateEntity: Entity<any>

      Entity to use as a template

    • force: boolean = false

      Force component replacement if it already exists on the target entity

    Returns Entity<any>

publicclearComponents

  • clearComponents(): void
  • Returns void

publicclearParticles

  • clearParticles(): void
  • Returns void

publicclone

  • Creates a deep copy of the entity and a copy of all its components


    Returns Actor

publiccontains

  • contains(x: number, y: number, recurse?: boolean): boolean
  • Tests whether the x/y specified are contained in the actor


    Parameters

    • x: number

      X coordinate to test (in world coordinates)

    • y: number

      Y coordinate to test (in world coordinates)

    • recurse: boolean = false

      checks whether the x/y are contained in any child actors (if they exist).

    Returns boolean

draw

publicemit

  • emit<TEventName>(eventName: TEventName, event: ActorEvents[TEventName]): void
  • emit(eventName: string, event?: any): void
  • Emits an event for target


    Type parameters

    Parameters

    • eventName: TEventName

      The name of the event to publish

    • event: ActorEvents[TEventName]

      Optionally pass an event data object to the handler

    Returns void

publicemitParticles

  • emitParticles(particleCount: number): void
  • Parameters

    • particleCount: number

    Returns void

get

publicgetAncestors

  • Returns a list of parent entities starting with the topmost parent. Includes the current entity.


    Returns Entity<any>[]

publicgetComponents

  • Returns all component instances on entity


    Returns Component[]

publicgetDescendants

  • getDescendants(): Entity<any>[]
  • Returns a list of all the entities that descend from this entity. Includes the current entity.


    Returns Entity<any>[]

publicgetGlobalPos

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

    @deprecated

    Use globalPos instead


    Returns Vector

    Position in world coordinates

publicgetGlobalRotation

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

    @deprecated

    Use globalRotation instead


    Returns number

    Rotation angle in radians

publicgetGlobalScale

  • Gets the global scale of the Actor

    @deprecated

    Use globalScale instead


    Returns Vector

publichas

  • Check if a component type exists


    Type parameters

    Parameters

    Returns boolean

hasAll

  • hasAll<TComponent>(requiredTypes: ComponentCtor<TComponent>[]): boolean
  • Verifies that an entity has all the required types


    Type parameters

    Parameters

    Returns boolean

hasAllTags

  • hasAllTags(requiredTags: string[]): boolean
  • Verifies that an entity has all the required tags


    Parameters

    • requiredTags: string[]

    Returns boolean

publichasTag

  • hasTag(tag: string): boolean
  • Check if a tag exists on the entity


    Parameters

    • tag: string

      name to check for

    Returns boolean

publicisKilled

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


    Returns boolean

publickill

  • 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

publicoff

  • off<TEventName>(eventName: TEventName, handler: Handler<ActorEvents[TEventName]>): void
  • off(eventName: string, handler: Handler<unknown>): void
  • off(eventName: string): void
  • 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.


    Type parameters

    Parameters

    • eventName: TEventName

      The name of the event to unsubscribe

    • handler: Handler<ActorEvents[TEventName]>

      Optionally the specific handler to unsubscribe

    Returns void

publicon

  • Subscribe an event handler to a particular event name, multiple handlers per event name are allowed.


    Type parameters

    Parameters

    • eventName: TEventName

      The name of the event to subscribe to

    • handler: Handler<ActorEvents[TEventName]>

      The handler callback to fire on this event

    Returns Subscription

publiconAdd

  • onAdd(engine: Engine<any>): void
  • onAdd is called when Actor is added to scene. This method is meant to be overridden.

    Synonymous with the event handler .on('add', (evt) => {...})


    Parameters

    Returns void

publiconCollisionEnd

  • Fires once when 2 entities with a ColliderComponent separate after having been in contact.


    Parameters

    Returns void

publiconCollisionStart

  • Fires once when 2 entities with a ColliderComponent first start colliding or touching, if the Colliders stay in contact this does not continue firing until they separate and re-collide.


    Parameters

    Returns void

publiconInitialize

  • onInitialize(engine: Engine<any>): 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

publiconPostCollisionResolve

  • Fires after every resolution for a confirmed contact.


    Parameters

    Returns void

publiconPostKill

  • onPostKill(scene: Scene<unknown>): 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

publiconPostUpdate

  • onPostUpdate(engine: Engine<any>, elapsed: 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<any>

      The reference to the current game engine

    • elapsed: number

      The time elapsed since the last update in milliseconds

    Returns void

publiconPreCollisionResolve

  • Fires before every collision resolution for a confirmed contact


    Parameters

    Returns void

publiconPreKill

  • onPreKill(scene: Scene<unknown>): 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

publiconPreUpdate

  • onPreUpdate(engine: Engine<any>, elapsed: 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<any>

      The reference to the current game engine

    • elapsed: number

      The time elapsed since the last update in milliseconds

    Returns void

publiconRemove

  • onRemove(engine: Engine<any>): void
  • onRemove is called when Actor is added to scene. This method is meant to be overridden.

    Synonymous with the event handler .on('remove', (evt) => {...})


    Parameters

    Returns void

publiconce

  • Once listens to an event once then auto unsubscribes from that event


    Type parameters

    Parameters

    • eventName: TEventName

      The name of the event to subscribe to once

    • handler: Handler<ActorEvents[TEventName]>

      The handler of the event that will be auto unsubscribed

    Returns Subscription

publicremoveAllChildren

  • removeAllChildren(): Entity<any>
  • Removes all children from this entity


    Returns Entity<any>

publicremoveChild

  • Remove an entity from children if it exists


    Parameters

    Returns Entity<any>

publicremoveComponent

  • removeComponent<TComponent>(typeOrInstance: TComponent | ComponentCtor<TComponent>, force?: boolean): Entity<Exclude<any, TComponent>>
  • 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


    Type parameters

    Parameters

    • typeOrInstance: TComponent | ComponentCtor<TComponent>
    • force: boolean = false

    Returns Entity<Exclude<any, TComponent>>

publicremoveTag

  • removeTag(tag: string): Entity<any>
  • Removes a tag on the entity

    Removals are deferred until the end of update


    Parameters

    • tag: string

    Returns Entity<any>

publicunkill

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


    Returns void

publicunparent

  • unparent(): void
  • Unparents this entity, if there is a parent. Otherwise it does nothing.


    Returns void

publicupdate

  • update(engine: Engine<any>, elapsed: number): void
  • Parameters

    • engine: Engine<any>
    • elapsed: number

    Returns void

publicwithin

  • within(actor: Actor, distance: number): boolean
  • Returns true if the two actor.collider's surfaces 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