Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Emitter

A particle emitter.

Hierarchy

  • Emitter

Index

Constructors

constructor

  • Parameters

    • particleParent: Container

      The container to add the particles to.

    • particleImages: any

      A texture or array of textures to use for the particles. Strings will be turned into textures via Texture.fromImage().

    • config: EmitterConfig | OldEmitterConfig

      A configuration object containing settings for the emitter.

    Returns Emitter

Properties

Protected _activeParticlesFirst

_activeParticlesFirst: Particle

The particles that are active and on the display list. This is the first particle in a linked list.

Protected _activeParticlesLast

_activeParticlesLast: Particle

The particles that are active and on the display list. This is the last particle in a linked list.

Protected _autoUpdate

_autoUpdate: boolean

If the update function is called automatically from the shared ticker. Setting this to false requires calling the update function manually.

Protected _completeCallback

_completeCallback: () => void

A callback for when all particles have died out. This is set by playOnceAndDestroy() or playOnce();

Type declaration

    • (): void
    • Returns void

Protected _currentImageIndex

_currentImageIndex: number = -1

A number keeping index of currently applied image. Used to emit arts in order.

Protected _destroyWhenComplete

_destroyWhenComplete: boolean

If the emitter should destroy itself when all particles have died out. This is set by playOnceAndDestroy();

Protected _emit

_emit: boolean

If particles should be emitted during update() calls. Setting this to false stops new particles from being created, but allows existing ones to die out.

Protected _emitterLife

_emitterLife: number

The life of the emitter in seconds.

Protected _frequency

_frequency: number

Time between particle spawns in seconds.

Protected _origArt

_origArt: any

The original particle image data that this emitter was initialized with.

Protected _origConfig

_origConfig: any

The original config object that this emitter was initialized with.

Protected _parent

_parent: Container

The container to add particles to.

Protected _particleConstructor

_particleConstructor: typeof Particle

The constructor used to create new particles. The default is the built in particle class.

Protected _poolFirst

_poolFirst: Particle

The particles that are not currently being used. This is the first particle in a linked list.

Protected _posChanged

_posChanged: boolean

If either ownerPos or spawnPos has changed since the previous update.

Protected _prevEmitterPos

_prevEmitterPos: Point

The origin + spawnPos in the previous update, so that the spawn position can be interpolated to space out particles better.

Protected _prevPosIsValid

_prevPosIsValid: boolean

If _prevEmitterPos is valid, to prevent interpolation on the first update

Protected _spawnFunc

_spawnFunc: (p: Particle, emitPosX: number, emitPosY: number, i?: number) => void

A reference to the emitter function specific to the spawn type.

Type declaration

    • (p: Particle, emitPosX: number, emitPosY: number, i?: number): void
    • Parameters

      • p: Particle
      • emitPosX: number
      • emitPosY: number
      • Optional i: number

      Returns void

Protected _spawnTimer

_spawnTimer: number

The timer for when to spawn particles in seconds, where numbers less than 0 mean that particles should be spawned.

acceleration

acceleration: Point

Acceleration to apply to particles. Using this disables any interpolation of particle speed. If the particles do not have a rotation speed, then they will be rotated to match the direction of travel.

addAtBack

addAtBack: boolean

If particles should be added at the back of the display list instead of the front.

angleStart

angleStart: number

Angle at which to start spawning particles in a burst.

customEase

customEase: SimpleEase

An easing function for nonlinear interpolation of values. Accepts a single parameter of time as a value from 0-1, inclusive. Expected outputs are values from 0-1, inclusive.

emitterLifetime

emitterLifetime: number

The amount of time in seconds to emit for before setting emit to false. A value of -1 is an unlimited amount of time.

extraData

extraData: any
Extra data for use in custom particles. The emitter doesn't look inside, but
passes it on to the particle to use in init().

maxLifetime

maxLifetime: number

The maximum lifetime for a particle, in seconds.

maxParticles

maxParticles: number

Maximum number of particles to keep alive at a time. If this limit is reached, no more particles will spawn until some have died.

maxRotationSpeed

maxRotationSpeed: number

The maximum rotation speed for a particle, in degrees per second. This only visually spins the particle, it does not change direction of movement.

maxSpeed

maxSpeed: number

The maximum speed allowed for accelerating particles. Negative values, values of 0 or NaN will disable the maximum speed.

maxStartRotation

maxStartRotation: number

The maximum start rotation for a particle, in degrees. This value is ignored if the spawn type is "burst" or "arc".

minLifetime

minLifetime: number

The minimum lifetime for a particle, in seconds.

minRotationSpeed

minRotationSpeed: number

The minimum rotation speed for a particle, in degrees per second. This only visually spins the particle, it does not change direction of movement.

minStartRotation

minStartRotation: number

The minimum start rotation for a particle, in degrees. This value is ignored if the spawn type is "burst" or "arc".

minimumScaleMultiplier

minimumScaleMultiplier: number

A minimum multiplier for the scale of a particle at all stages of its life. A value between minimumScaleMultiplier and 1 is randomly generated for each particle.

minimumSpeedMultiplier

minimumSpeedMultiplier: number

A minimum multiplier for the speed of a particle at all stages of its life. A value between minimumSpeedMultiplier and 1 is randomly generated for each particle.

noRotation

noRotation: boolean

If no particle rotation should occur. Starting rotation will still affect the direction in which particles move. If the rotation speed is set, then this will be ignored.

Protected ownerPos

ownerPos: Point

The world position of the emitter's owner, to add spawnPos to when spawning particles. To change this, use updateOwnerPos().

particleBlendMode

particleBlendMode: number

The blend mode for all particles, as named by PIXI.blendModes.

particleCount

particleCount: number

The current number of active particles.

particleImages

particleImages: any[]

An array of PIXI Texture objects.

particleSpacing

particleSpacing: number

Spacing between particles in a burst. 0 gives a random angle for each particle.

particlesPerWave

particlesPerWave: number

Number of particles to spawn time that the frequency allows for particles to spawn.

Protected rotation

rotation: number

Rotation of the emitter or emitter's owner in degrees. This is added to the calculated spawn angle. To change this, use rotate().

rotationAcceleration

rotationAcceleration: number

The Acceleration of rotation (angular acceleration) for a particle, in degrees per second.

spawnChance

spawnChance: number

Chance that a particle will be spawned on each opportunity to spawn one. 0 is 0%, 1 is 100%.

spawnCircle

spawnCircle: Circle & { minRadius: number }

A circle relative to spawnPos to spawn particles inside if the spawn type is "circle".

spawnPolygonalChain

spawnPolygonalChain: PolygonalChain

A polygon relative to spawnPos to spawn particles on the chain if the spawn type is "polygonalChain".

spawnPos

spawnPos: Point

Position at which to spawn particles, relative to the emitter's owner's origin. For example, the flames of a rocket travelling right might have a spawnPos of {x:-50, y:0}. to spawn at the rear of the rocket. To change this, use updateSpawnPos().

spawnRect

spawnRect: Rectangle

A rectangle relative to spawnPos to spawn particles inside if the spawn type is "rect".

spawnType

spawnType: string

How the particles will be spawned. Valid types are "point", "rectangle", "circle", "burst", "ring".

startAlpha

startAlpha: PropertyNode<number>

The first node in the list of alpha values for all particles.

startColor

startColor: PropertyNode<Color>

The first node in the list of color values of all particles, as red, green, and blue uints from 0-255.

startScale

startScale: PropertyNode<number>

The first node in the list of scale values of all particles.

startSpeed

startSpeed: PropertyNode<number>

The first node in the list of speed values of all particles.

Accessors

autoUpdate

  • get autoUpdate(): boolean
  • set autoUpdate(value: boolean): void
  • If the update function is called automatically from the shared ticker. Setting this to false requires calling the update function manually.

    Returns boolean

  • If the update function is called automatically from the shared ticker. Setting this to false requires calling the update function manually.

    Parameters

    • value: boolean

    Returns void

emit

  • get emit(): boolean
  • set emit(value: boolean): void
  • If particles should be emitted during update() calls. Setting this to false stops new particles from being created, but allows existing ones to die out.

    Returns boolean

  • If particles should be emitted during update() calls. Setting this to false stops new particles from being created, but allows existing ones to die out.

    Parameters

    • value: boolean

    Returns void

frequency

  • get frequency(): number
  • set frequency(value: number): void
  • Time between particle spawns in seconds. If this value is not a number greater than 0, it will be set to 1 (particle per second) to prevent infinite loops.

    Returns number

  • Time between particle spawns in seconds. If this value is not a number greater than 0, it will be set to 1 (particle per second) to prevent infinite loops.

    Parameters

    • value: number

    Returns void

orderedArt

  • get orderedArt(): boolean
  • set orderedArt(value: boolean): void
  • If the emitter is using particle art in order as provided in particleImages. Effective only when particleImages has multiple art options. This is particularly useful ensuring that each art shows up once, in case you need to emit a body in an order. For example: dragon - [Head, body1, body2, ..., tail]

    Returns boolean

  • If the emitter is using particle art in order as provided in particleImages. Effective only when particleImages has multiple art options. This is particularly useful ensuring that each art shows up once, in case you need to emit a body in an order. For example: dragon - [Head, body1, body2, ..., tail]

    Parameters

    • value: boolean

    Returns void

parent

  • get parent(): Container
  • set parent(value: Container): void
  • The container to add particles to. Settings this will dump any active particles.

    Returns Container

  • The container to add particles to. Settings this will dump any active particles.

    Parameters

    • value: Container

    Returns void

particleConstructor

  • get particleConstructor(): typeof Particle
  • set particleConstructor(value: Particle): void
  • The constructor used to create new particles. The default is the built in Particle class. Setting this will dump any active or pooled particles, if the emitter has already been used.

    Returns typeof Particle

  • The constructor used to create new particles. The default is the built in Particle class. Setting this will dump any active or pooled particles, if the emitter has already been used.

    Parameters

    Returns void

Methods

Protected _spawnBurst

  • _spawnBurst(p: Particle, emitPosX: number, emitPosY: number, i: number): void
  • Positions a particle for a burst type emitter.

    Parameters

    • p: Particle

      The particle to position and rotate.

    • emitPosX: number

      The emitter's x position

    • emitPosY: number

      The emitter's y position

    • i: number

      The particle number in the current wave.

    Returns void

Protected _spawnCircle

  • _spawnCircle(p: Particle, emitPosX: number, emitPosY: number): void
  • Positions a particle for a circle type emitter.

    Parameters

    • p: Particle

      The particle to position and rotate.

    • emitPosX: number

      The emitter's x position

    • emitPosY: number

      The emitter's y position

    Returns void

Protected _spawnPoint

  • _spawnPoint(p: Particle, emitPosX: number, emitPosY: number): void
  • Positions a particle for a point type emitter.

    Parameters

    • p: Particle

      The particle to position and rotate.

    • emitPosX: number

      The emitter's x position

    • emitPosY: number

      The emitter's y position

    Returns void

Protected _spawnPolygonalChain

  • _spawnPolygonalChain(p: Particle, emitPosX: number, emitPosY: number): void
  • Positions a particle for polygonal chain.

    Parameters

    • p: Particle

      The particle to position and rotate.

    • emitPosX: number

      The emitter's x position

    • emitPosY: number

      The emitter's y position

    Returns void

Protected _spawnRect

  • _spawnRect(p: Particle, emitPosX: number, emitPosY: number): void
  • Positions a particle for a rectangle type emitter.

    Parameters

    • p: Particle

      The particle to position and rotate.

    • emitPosX: number

      The emitter's x position

    • emitPosY: number

      The emitter's y position

    Returns void

Protected _spawnRing

  • _spawnRing(p: Particle, emitPosX: number, emitPosY: number): void
  • Positions a particle for a ring type emitter.

    Parameters

    • p: Particle

      The particle to position and rotate.

    • emitPosX: number

      The emitter's x position

    • emitPosY: number

      The emitter's y position

    Returns void

Protected applyAdditionalProperties

  • applyAdditionalProperties(p: Particle): void
  • Set additional properties to new particle. Using on classes that extend from Emitter

    Parameters

    Returns void

cleanup

  • cleanup(): void

destroy

  • destroy(): void

init

  • Sets up the emitter based on the config settings.

    Parameters

    • art: any

      A texture or array of textures to use for the particles.

    • config: EmitterConfig | OldEmitterConfig

      A configuration object containing settings for the emitter.

    Returns void

Protected initAdditional

  • Sets up additional parameters to the emitter from config settings. Using for parsing additional parameters on classes that extend from Emitter

    Parameters

    • art: any

      A texture or array of textures to use for the particles.

    • config: EmitterConfig | OldEmitterConfig

      A configuration object containing settings for the emitter.

    Returns void

Protected parseSpawnType

  • Parsing emitter spawn type from config settings. Place for override and add new kind of spawn type

    Parameters

    Returns void

playOnce

  • playOnce(callback?: () => void): void
  • Starts emitting particles and optionally calls a callback when particle emission is complete.

    Parameters

    • Optional callback: () => void

      Callback for when emission is complete (all particles have died off)

        • (): void
        • Returns void

    Returns void

playOnceAndDestroy

  • playOnceAndDestroy(callback?: () => void): void
  • Starts emitting particles, sets autoUpdate to true, and sets up the Emitter to destroy itself when particle emission is complete.

    Parameters

    • Optional callback: () => void

      Callback for when emission is complete (all particles have died off)

        • (): void
        • Returns void

    Returns void

recycle

  • Recycles an individual particle. For internal use only.

    internal

    Parameters

    • particle: Particle

      The particle to recycle.

    Returns void

resetPositionTracking

  • resetPositionTracking(): void
  • Prevents emitter position interpolation in the next update. This should be used if you made a major position change of your emitter's owner that was not normal movement.

    Returns void

rotate

  • rotate(newRot: number): void
  • Sets the rotation of the emitter to a new value.

    Parameters

    • newRot: number

      The new rotation, in degrees.

    Returns void

update

  • update(delta: number): void
  • Updates all particles spawned by this emitter and emits new ones.

    Parameters

    • delta: number

      Time elapsed since the previous frame, in seconds.

    Returns void

updateOwnerPos

  • updateOwnerPos(x: number, y: number): void
  • Changes the position of the emitter's owner. You should call this if you are adding particles to the world container that your emitter's owner is moving around in.

    Parameters

    • x: number

      The new x value of the emitter's owner.

    • y: number

      The new y value of the emitter's owner.

    Returns void

updateSpawnPos

  • updateSpawnPos(x: number, y: number): void
  • Changes the spawn position of the emitter.

    Parameters

    • x: number

      The new x value of the spawn position for the emitter.

    • y: number

      The new y value of the spawn position for the emitter.

    Returns void

Generated using TypeDoc