Foundation.NonReactiveParticle

A tile-based particle controlled by a ParticleEmitter. As the name might suggest, this particle type cannot interact with its surroundings, it's a purely visual element.

In the strictest sense, Foundation doesn't allow for particles (single points). This type is image-based and is axis-aligned. Because of this, dense particle systems are unlikely to run efficiently, but hundreds of these items on screen at a time should be fine on mid-range desktop machines.

Objects of this type are created by a ParticleEmitter, and the emitter controls their life cycle (including rendering). Do not add individual particles to a game. Do not manually create particles, the type is only documented here for deriving purposes.


Implementation Details

Reference paths

  • '/foundation/_digest.ts'
  • '/foundation/core/actors/_digest.ts'
  • '/foundation/core/actors/NonReactiveParticle.ts'

Extends

This type extends:

The image property getter returns the image set in the back-referenced emitter (the particles do not have their own image).

Implements

This type does not implement any interfaces.


Public Properties

emitter: ParticleEmitter

  • Get or set a back-reference to the particle's emitter.

directionDT: Vector2

  • The particle's travel direction.

velocityDT: number

  • The number of world units the particle should travel per second.

alphaDT: number

  • The alpha change which should occur in the particle per second.
  • Alpha is clamped to [0,1].
  • A positive or negative value can be used.

life: number

  • The particle's allowed lifetime in seconds. E.g. 1.5 will keep the particle alive for 1.5 seconds.

Constructors

(bounds: Rectangle, emitter: ParticleEmitter)

  • bounds: The starting position and size of the particle.
  • emitter: Back-reference to the owning emitter.

Instance Methods

resetProperties(positionX: number, positionY: number, alpha: number, directionX: number, directionY: number, velocityDT: number, alphaDT: number, life: number)

  • Reset particle state. Internal storage structures are reused.
  • positionX and positionY will be normalized.