Interface

PosComp

:

The pos component.

group Component Types

pos

: Vec2

Object's current world position.

move

(xVel: number, yVel: number): void

Move how many pixels per second. If object is 'solid', it won't move into other 'solid' objects.

move

(vel: Vec2): void

moveBy

(dx: number, dy: number): void

Move how many pixels, without multiplying dt, but still checking for 'solid'.

moveBy

(d: Vec2): void

moveTo

(dest: Vec2, speed?: number): void

Move to a spot with a speed (pixels per second), teleports if speed is not given.

moveTo

(x: number, y: number, speed?: number): void

screenPos

(newPos?: Vec2): Vec2 | null

Get / Set the position of the object on the screen.

since v2000.0

worldPos

(newPos?: Vec2): Vec2 | null

Get / Set the position of the object relative to the root.

since v2000.0

toScreen

(this: GameObj<PosComp | FixedComp>, p: Vec2): Vec2

Transform a local point (relative to this) to a screen point (relative to the camera)

toWorld

(this: GameObj<PosComp>, p: Vec2): Vec2

Transform a local point (relative to this) to a world point (relative to the root)

since v3001.0

fromScreen

(this: GameObj<PosComp | FixedComp>, p: Vec2): Vec2

Transform a screen point (relative to the camera) to a local point (relative to this)

since v3001.0

fromWorld

(this: GameObj<PosComp>, p: Vec2): Vec2

Transform a world point (relative to the root) to a local point (relative to this)

since v3001.0

toOther

(this: GameObj<PosComp>, other: GameObj<PosComp>, p: Vec2): Vec2

Transform a point relative to this to a point relative to other

since v3001.0

fromOther

(this: GameObj<PosComp>, other: GameObj<PosComp>, p: Vec2): Vec2

Transform a point relative to other to a point relative to this

since v3001.0

kaplay logo

Layer

Miscalenous