This example demonstrates the particle system with UIEmitter. Particles rise from the bottom of the screen with physics-based behaviors including gravity, velocity damping, and rotation.
const emitter = new UIEmitter(
layer,
[
new UISpawnRectangle([-960, 0], [960, 0]),
new UISpawnRandomRotation([-Math.PI, Math.PI]),
new UISpawnRandomTorque([-Math.PI, Math.PI]),
new UISpawnRandomScale([1, 10]),
new UISpawnRandomLifetime([10, 20]),
],
[
new UIBehaviorDirectionalGravity({ x: 0, y: 50 }),
new UIBehaviorVelocityNoise(1, 200),
new UIBehaviorVelocityDamping({ min: 0.25, max: 0.75 }),
new UIBehaviorTorqueNoise(1, 100),
new UIBehaviorTorqueDamping(0.25),
],
[
new UITextureRenderingModule(dustTexture),
new UIRenderingColorOverLife([
new UIColor(0xfc9337, 0.25),
new UIColor(0xb77a59, 0.25),
new UIColor(0xb77a59, 0),
]),
],
{ expectedCapacity: 1024 }
);
emitter.play(16);