Class: Particle

Particle

Represents a single particle within a particle container. This class implements the IParticle interface, providing properties and methods to manage the particle's position, scale, rotation, color, and texture.

The reason we use a particle over a sprite is that these are much lighter weight and we can create a lot of them without taking on the overhead of a full sprite.

Here is an example of how to create a new particle:

const particle = new Particle({
  texture,
  x: 100,
  y: 100,
  scaleX: 0.5,
  scaleY: 0.5,
  rotation: Math.PI / 2,
  color: 0xff0000,
});

Implements

  • {IParticle}

Members

defaultOptions Partial<ParticleOptions> static

Default options for constructing with options

alpha number

Gets or sets the alpha value of the particle.

anchorX number

The x-coordinate of the anchor point.

anchorY number

The y-coordinate of the anchor point.

color number

The color of the particle as a hexadecimal number.

rotation number

The rotation of the particle in radians.

scaleX number

The scale factor in the x-axis.

scaleY number

The scale factor in the y-axis.

texture Texture

The texture of the particle.

tint number

Gets or sets the tint color of the particle.

x number

The x-coordinate of the particle.

y number

The y-coordinate of the particle.