Skip to content
party.js logoparty.js logo

ReferenceBehaviorsType

BehaviorInit

Prepares a newly spawned particle for a behavior.

type BehaviorInit = (particle: Particle, ctx: BehaviorInitContext) => void;

A function that prepares a newly spawned particle for a behavior.

Called once per particle right after it has been constructed, but before its first update. Initializations are called in the order that the behaviors are listed in.

A common use case is to remember initial particle data or to choose a random initial value for a behavior via the random number generator.

particleParticle

The new particle.

ctxBehaviorInitContext

The context supplied to the initialization, including the random number generator.