ReferenceScripting APIParticleComponent
ParticleComponent
classA particle layer of a mote.
| Name | ParticleComponent |
|---|---|
| Kind | class |
| Script reaches it as | import { ParticleComponent } from "motion" |
| Since | 0.3 |
Syntax
class ParticleComponent extends Component { … }Properties
| Name | Type | Description |
|---|---|---|
nameproperty | readonly string | Its name on its mote. |
layerproperty | readonly string | Its layer's id. |
visibleproperty | boolean | Whether its layer shows. |
opacityproperty | number | Its layer's opacity, 0 to 1. |
aliveproperty | readonly number | How many particles are alive, as its last step counted. |
pausedproperty | readonly boolean | Whether its spawning is paused. |
Methods
| Signature | Description |
|---|---|
new ParticleComponent(name?: string, layer?: string): ParticleComponentconstructor | Binds 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): voidmethod | Changes one of its layer's settings. |
animate(key: string, value: string | number, seconds: number, options?: MotionAnimateOptions): Promise<boolean>method | Moves one of its layer's settings. |
stopAnimating(key?: string): voidmethod | Stops its layer's moves. |
get(key: string): SettingValue | undefinedmethod | One of its layer's settings, as scene.get. |
read(key: string): SettingValue | undefinedmethod | One of its layer's settings as last drawn, as scene.read. |
show(visible?: boolean): voidmethod | Shows (or hides) its layer. |
hide(): voidmethod | Hides its layer. |
burst(count?: number, at?: [number, number] | { x: number; y: number }, emitter?: string | number): voidmethod | Fires a burst of particles. |
setRate(perSecond: number, emitter?: string | number): voidmethod | Sets how many particles an emitter makes a second, in place of its own rate. |
resetRate(emitter?: string | number): voidmethod | Gives an emitter (or every one) its own rate back. |
pause(): voidmethod | Stops the system making particles; those alive live out their lives. |
resume(): voidmethod | Lets it make particles again. |
clear(): voidmethod | Takes every particle away at once, and the bursts waiting. |
See also
Notes from the community
Written by creators and checked by the docs' editors. Not part of Motion's official reference.