createMovable2D

View sourcecreateMovable2D(x?: number, y?: number, a?: number): [Position2D, Orientation2D, Scale2D, GlobalTransform2D, Velocity2D, Rotation2D, Acceleration2D, Torque2D]

Creates an ordered 2D transform and motion component bundle.

The returned tuple is ready for World#spawn and contains, in insertion order, Position2D, Orientation2D, Scale2D, GlobalTransform2D, Velocity2D, Rotation2D, Acceleration2D, and Torque2D. Position defaults to (0, 0), the angle defaults to 0 radians, scale defaults to (1, 1), and all motion components default to zero.

Examples

import { World } from '@wimaengine/ecs'
import { createMovable2D } from '@wimaengine/movable'

const world = new World()
world.spawn(createMovable2D(10, 20, Math.PI / 4))

Parameters

NameDescriptionDefault
x?

Initial x position.

0
y?

Initial y position.

0
a?

Initial 2D angle in radians.

0

Returns

Ordered transform and motion components.