Interface

LevelComp

:

The level component.

group Component Types

tileWidth

(): number

tileHeight

(): number

numRows

(): number

numColumns

(): number

spawn

(sym: string, p: Vec2): GameObj | null

Spawn a tile from a symbol defined previously.

spawn

(sym: string, x: number, y: number): GameObj | null

spawn

(obj: CompList<T>, p: Vec2): GameObj<T> | null

Spawn a tile from a component list.

returns The spawned game object, or null if the obj hasn't components.

spawn

(sym: CompList<T>, x: number, y: number): GameObj<T> | null

levelWidth

(): number

Total width of level in pixels.

levelHeight

(): number

Total height of level in pixels.

getAt

(tilePos: Vec2): GameObj[]

Get all game objects that's currently inside a given tile.

raycast

(origin: Vec2, direction: Vec2): RaycastResult

Raycast all game objects on the given path.

tile2Pos

(tilePos: Vec2): Vec2

Convert tile position to pixel position.

tile2Pos

(x: number, y: number): Vec2

pos2Tile

(pos: Vec2): Vec2

Convert pixel position to tile position.

pos2Tile

(x: number, y: number): Vec2

getTilePath

(from: Vec2, to: Vec2, opts?: PathFindOpt): Vec2[] | null

Find the path to navigate from one tile to another tile.

returns A list of traverse points in tile positions.

getPath

(from: Vec2, to: Vec2, opts?: PathFindOpt): Vec2[] | null

Find the path to navigate from one tile to another tile.

returns A list of traverse points in pixel positions.

getSpatialMap

(): GameObj[][]

removeFromSpatialMap

(obj: GameObj): void

insertIntoSpatialMap

(obj: GameObj): void

onSpatialMapChanged

(cb: () => void): KEventController

onNavigationMapInvalid

(cb: () => void): KEventController

invalidateNavigationMap

(): void

onNavigationMapChanged

(cb: () => void): KEventController
kaplay logo

Layer

Miscalenous