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
// Apply a static texture to all particles.
textureBehavior.applyConfig({
textureConfigs: [{ textures: [PIXI.Texture.from("particle.png")] }],
mode: "static",
});Extends
EmitterBehavior<TextureBehaviorConfig,DataType,ParticleType>
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
InitBehavior<DataType,ParticleType>UpdateBehavior<DataType,ParticleType>
Constructors
Constructor
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
Accessors
updateOrder
Get Signature
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
Implementation of
Overrides
Methods
applyConfig()
applyConfig(config): void;Reset the behavior and apply the provided configuration.
Parameters
config
Behavior configuration.
Returns
void
Implementation of
Overrides
getConfig()
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
Overrides
init()
init(particle): void;Initialize the particle.
Parameters
particle
ParticleType
Particle to initialize.
Returns
void
Implementation of
reset()
protected reset(): void;Reset the behavior to its default state.
Returns
void
Implementation of
Overrides
update()
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