Motion
Get Motion

ReferenceScripting APIStage

Stage

class

The scene's own: one is made, to hear the scene; it has all of the stage's.

NameStage
Kindclass
Script reaches it asimport { Stage } from "motion"
Since0.3

Syntax

class Stage { … }

Properties

NameTypeDescription
timepropertyreadonly numberThe scene's time, seconds.
widthpropertyreadonly numberThe scene's width, pixels.
heightpropertyreadonly numberThe scene's height, pixels.
motespropertyreadonly Mote[]Every mote.
stagepropertyreadonly MotionStageApiThe stage itself.
gravitypropertyreadonly Vector3The 2D world's gravity, pixels a second a second (y down).

Methods

SignatureDescription
new Stage(): StageconstructorMade once, by the scene as it starts: don't make one yourself.
spawn<M extends Mote>(cls: string | () => M, options?: { location?: Place; rotation?: number | number[] | Rotator; scale?: number | Place; name?: string; properties?: Record<string, unknown>; tags?: string[] }): MmethodMakes a mote of a class.
destroy(mote: Mote): voidmethodTakes a mote out of the scene.
find<M extends Mote>(cls: string | () => M): M | nullmethodThe first mote of a class.
findAll<M extends Mote>(cls: string | () => M): M[]methodEvery mote of a class (its subclasses' too).
withTag(tag: string): Mote[]methodEvery mote with a tag.
byId(id: string): Mote | nullmethodA mote by its id.
byName(name: string): Mote | nullmethodA mote by its name.
randomPointInView(): Vector3methodA random point on the scene, its pixels.
castRay(from: Place, to: Place, options?: { world?: "2d" | "3d" }): Promise<MotionRayHit | null>methodThe first mote's body a ray from one point to another meets, next turn.
setGravity(v: Place, world?: "2d" | "3d"): voidmethodSets a world's gravity.
join(a: string | Mote, b: string | Mote, joint?: MotionJointSpec): numbermethodJoins two motes' bodies.
unjoin(id: number): voidmethodLets a joint go.
onStart(): voidmethodIt started.
onTick(dt: number): voidmethodEach tick.
onSettingsChanged(props: Record<string, any>): voidmethodThe wallpaper's settings changed.

See also

Mote · MotionStageApi · Vector3 · MotionRayHit