createEmitter2D

View sourcecreateEmitter2D(prefab?: EmitterOptions, x?: number, y?: number, angle?: number): [Position2D, Orientation2D, Scale2D, GlobalTransform2D, Emitter, Timer, Children]

Creates the component bundle for a 2D particle emitter entity.

The returned tuple contains Position2D, Orientation2D, Scale2D, GlobalTransform2D, Emitter, Timer, and Children in insertion order. The transform starts at the supplied position and angle, with unit scale; omitted position and angle arguments use the defaults of createTransform2D. The optional prefab object is forwarded to Emitter as its constructor options.

Examples

import { World } from '@wimaengine/ecs'
import { createEmitter2D } from '@wimaengine/emitter'

const world = new World()
world.spawn(createEmitter2D({ prefab: () => [] }, 10, 20, Math.PI / 4))

Parameters

NameDescriptionDefault
prefab?

Options forwarded to Emitter.

—
x?

Initial x position.

—
y?

Initial y position.

—
angle?

Initial 2D angle.

—

Returns

Ordered component bundle containing Position2D, Orientation2D, Scale2D, GlobalTransform2D, Emitter, Timer, and Children.