Options
All
  • Public
  • Public/Protected
  • All
Menu

Using a particle emitter is a great way to create interesting effects in your game, like smoke, fire, water, explosions, etc. ParticleEmitter extend Actor allowing you to use all of the features that come with.

Hierarchy

Index

Constructors

Properties

acceleration: Vector = ...

Gets or sets the acceleration vector for all particles

active: boolean = true

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

beginColor: Color = Color.White

Gets or sets the beginning color of all particles

childrenAdded$: Util.Observable<Entity> = ...
childrenRemoved$: Util.Observable<Entity> = ...
componentAdded$: Util.Observable<AddedComponent> = ...

Observable that keeps track of component add or remove changes on the entity

componentRemoved$: Util.Observable<RemovedComponent> = ...
deadParticles: Particle[] = []

Gets or sets the backing deadParticle collection

emitRate: number = 1

Gets or sets the emission rate for particles (particles/sec)

emitterType: EmitterType = EmitterType.Rectangle

Gets or sets the emitter type for the particle emitter

endColor: Color = Color.White

Gets or sets the ending color of all particles

endSize: number = null

Gets or sets the optional ending size for the particles

eventDispatcher: EventDispatcher<any>

Direct access to the game object event dispatcher.

fadeFlag: boolean = false

Gets or sets the fade flag which causes particles to gradually fade out over the course of their life.

focus: Vector = null

Gets or sets the optional focus where all particles should accelerate towards

focusAccel: number = null

Gets or sets the acceleration for focusing particles if a focus has been specified

id: number = ...

The unique identifier for the entity

isEmitting: boolean = true

Gets or sets the isEmitting flag

logger: Util.Logger = ...

Convenience reference to the global logger

maxAngle: number = 0

Gets or sets the maximum angle in radians

maxSize: number = 5

Gets or sets the maximum size of all particles

maxVel: number = 0

Gets or sets the maximum particle velocity

minAngle: number = 0

Gets or sets the minimum angle in radians

minSize: number = 5

Gets or sets the minimum size of all particles

minVel: number = 0

Gets or sets the minimum particle velocity

numParticles: number = 0
particleLife: number = 2000

Gets or sets the life of each particle in milliseconds

particleRotationalVelocity: number = 0

Gets or sets the particle rotational speed velocity

particles: Particle[] = []

Gets or sets the backing particle collection

radius: number = 0

Gets or sets the emitter radius, only takes effect when the emitterType is EmitterType.Circle

random: Random

Random number generator

randomRotation: boolean = false

Indicates whether particles should start with a random rotation

scene: Scene<unknown> = null

The scene that the entity is in, if any

startSize: number = null

Gets or sets the optional starting size for the particles

defaults: { anchor: Vector } = ...

Set defaults for all Actors

Type declaration

Accessors

  • 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

  • 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

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

    Returns BodyComponent

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

    Returns Vector

  • get children(): readonly Entity[]
  • Sets the color of the actor's current graphic

    Returns Color

  • Sets the color of the actor's current graphic

    Parameters

    Returns void

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

  • Parameters

    • isDraggable: boolean

    Returns void

  • get height(): number
  • Returns number

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

    Returns boolean

  • Get the local center point of an actor

    Returns Vector

  • get name(): string
  • 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

  • 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

  • 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

  • get opacity(): number
  • set opacity(opacity: number): void
  • Gets the opacity of each particle from 0 to 1.0

    Returns number

  • Gets the opacity of each particle from 0 to 1.0

    Parameters

    • opacity: number

    Returns void

  • get particleSprite(): Sprite
  • set particleSprite(val: Sprite): void
  • Gets the position vector of the actor in pixels

    Returns Vector

  • Sets the position vector of the actor in pixels

    Parameters

    Returns void

  • 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

  • get tags(): readonly string[]
  • get types(): string[]
  • 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

  • get width(): number
  • Returns number

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

    • newZ: number

      new z-index to assign

    Returns void

Methods

  • _initialize(engine: Engine): void
  • 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

    Parameters

    Returns void

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

    Internal _prekill handler for onPostKill lifecycle event

    internal

    Parameters

    Returns void

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

    Internal _preupdate handler for onPostUpdate lifecycle event

    internal

    Parameters

    Returns void

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

    Internal _prekill handler for onPreKill lifecycle event

    internal

    Parameters

    Returns void

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

    Internal _preupdate handler for onPreUpdate lifecycle event

    internal

    Parameters

    Returns void

  • _setName(name: string): void
  • addComponent<T>(component: T, force?: boolean): Entity
  • addTemplate(templateEntity: Entity, force?: boolean): Entity
  • Adds a copy of all the components from another template entity as a "prefab"

    Parameters

    • templateEntity: Entity

      Entity to use as a template

    • force: boolean = false

      Force component replacement if it already exists on the target entity

    Returns Entity

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

  • emit(eventName: string, eventObject: any): void
  • Emits a new event

    Parameters

    • eventName: string

      Name of the event to emit

    • eventObject: any

      Data associated with this event

    Returns void

  • emitParticles(particleCount: number): void
  • Causes the emitter to emit particles

    Parameters

    • particleCount: number

      Number of particles to emit right now

    Returns void

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

    Returns Vector

    Position in world coordinates

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

    Returns number

    Rotation angle in radians

  • has<T>(type: ComponentCtor<T>): boolean
  • has(type: string): boolean
  • hasTag(tag: string): boolean
  • isKilled(): boolean
  • 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

  • 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

  • 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

  • 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

    Returns void

  • 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

  • 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

    Returns void

  • removeComponent<ComponentOrType>(componentOrType: ComponentOrType, force?: boolean): 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

    Type Parameters

    • ComponentOrType extends string | Component<string>

    Parameters

    • componentOrType: ComponentOrType
    • force: boolean = false

    Returns Entity

  • removeParticle(particle: Particle): void
  • removeTag(tag: string, force?: boolean): Entity
  • unkill(): void
  • If the current actor is killed, it will now not be killed.

    Returns void

  • unparent(): void
  • update(engine: Engine, delta: number): void
  • 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