Class
Velocity2D
View sourceExtendsVector2
Stores an entity’s linear velocity in 2D as an ECS component.
Its x and y values describe movement along the two axes in coordinate
units per second. A new component starts at (0, 0). Pair it with
Position2D for an entity’s 2D position and Acceleration2D
for a change in velocity.
Examples
import { Velocity2D } from '@wimaengine/movable'
import { Query, World } from '@wimaengine/ecs'
const world = new World()
world.spawn([new Velocity2D(2, -1)])
new Query(world, [Velocity2D]).each(([velocity]) => {
velocity.x = 3
velocity.y = 0
})Constructor
View source
Methods
staticcopy(source: Velocity2D, target?: Velocity2D): Velocity2D
View sourcestaticclone(target: Velocity2D): Velocity2D
View sourceCreates a new Velocity2D with the same coordinates as another one.
