Skip to content

TextureBehavior<DataType, ParticleType>

Behavior used to control the texture of particles over their lifetime.

Behavior supports three modes, a static mode where a single texture is applied to all particles, a random mode where a random texture from the provided textures is applied to the particle upon initialization, and an animated mode where textures are animated over the particle's lifetime based on the provided configuration.

See

TextureBehaviorConfig for configuration options.

Example

ts
// Apply a static texture to all particles.
textureBehavior.applyConfig({
    textureConfigs: [{ textures: [PIXI.Texture.from("particle.png")] }],
    mode: "static",
});

Extends

Type Parameters

DataType

DataType extends BaseParticleData

Type describing the data object stored on particles.

ParticleType

ParticleType extends IEmitterParticle<DataType> = IEmitterParticle<DataType>

Type describing the particle used within the emitter.

Implements

Constructors

Constructor

ts
new TextureBehavior<DataType, ParticleType>(emitter): TextureBehavior<DataType, ParticleType>;

Creates a new instance of the behavior.

Parameters

emitter

Emitter<DataType, ParticleType>

Emitter instance this behavior belongs to.

Returns

TextureBehavior<DataType, ParticleType>

Inherited from

EmitterBehavior.constructor

Accessors

updateOrder

Get Signature

ts
get updateOrder(): BehaviorOrder;

Defines at which step of the update cycle the behavior is applied.

  • initial: Earliest step, useful when other behaviors depend on this behavior.
  • normal: Default step for most behaviors.
  • late: Latest step, useful for behaviors that should override others or depend on their properties.
Returns

BehaviorOrder

Implementation of

UpdateBehavior.updateOrder

Overrides

EmitterBehavior.updateOrder

Methods

applyConfig()

ts
applyConfig(config): void;

Reset the behavior and apply the provided configuration.

Parameters

config

TextureBehaviorConfig

Behavior configuration.

Returns

void

Implementation of

UpdateBehavior.applyConfig

Overrides

EmitterBehavior.applyConfig


getConfig()

ts
getConfig():
  | TextureBehaviorConfig
  | undefined;

Retrieve the current behavior properties as a configuration object. If the behavior is inactive, undefined is returned.

Returns

| TextureBehaviorConfig | undefined

Behavior configuration object or undefined if inactive.

Implementation of

UpdateBehavior.getConfig

Overrides

EmitterBehavior.getConfig


init()

ts
init(particle): void;

Initialize the particle.

Parameters

particle

ParticleType

Particle to initialize.

Returns

void

Implementation of

InitBehavior.init


reset()

ts
protected reset(): void;

Reset the behavior to its default state.

Returns

void

Implementation of

UpdateBehavior.reset

Overrides

EmitterBehavior.reset


update()

ts
update(particle, deltaTime): void;

Updates the particle.

Parameters

particle

ParticleType

Particle to update.

deltaTime

number

Time elapsed since the last update, in seconds.

Returns

void

Implementation of

UpdateBehavior.update