Motion
Get Motion

ReferenceScripting APIParticleComponent

ParticleComponent

class

A particle layer of a mote.

NameParticleComponent
Kindclass
Script reaches it asimport { ParticleComponent } from "motion"
Since0.3

Syntax

class ParticleComponent extends Component { … }

Properties

NameTypeDescription
namepropertyreadonly stringIts name on its mote.
layerpropertyreadonly stringIts layer's id.
visiblepropertybooleanWhether its layer shows.
opacitypropertynumberIts layer's opacity, 0 to 1.
alivepropertyreadonly numberHow many particles are alive, as its last step counted.
pausedpropertyreadonly booleanWhether its spawning is paused.

Methods

SignatureDescription
new ParticleComponent(name?: string, layer?: string): ParticleComponentconstructorBinds a layer to a mote by hand. A mote's components are made with it, from the layers it's given in Studio, so you rarely need this.
set(key: string, value: SettingValue): voidmethodChanges one of its layer's settings.
animate(key: string, value: string | number, seconds: number, options?: MotionAnimateOptions): Promise<boolean>methodMoves one of its layer's settings.
stopAnimating(key?: string): voidmethodStops its layer's moves.
get(key: string): SettingValue | undefinedmethodOne of its layer's settings, as scene.get.
read(key: string): SettingValue | undefinedmethodOne of its layer's settings as last drawn, as scene.read.
show(visible?: boolean): voidmethodShows (or hides) its layer.
hide(): voidmethodHides its layer.
burst(count?: number, at?: [number, number] | { x: number; y: number }, emitter?: string | number): voidmethodFires a burst of particles.
setRate(perSecond: number, emitter?: string | number): voidmethodSets how many particles an emitter makes a second, in place of its own rate.
resetRate(emitter?: string | number): voidmethodGives an emitter (or every one) its own rate back.
pause(): voidmethodStops the system making particles; those alive live out their lives.
resume(): voidmethodLets it make particles again.
clear(): voidmethodTakes every particle away at once, and the bursts waiting.

See also

SettingValue