LittleJS 1.28.0

Editor

LittleJS Level Editor

  • Paint the game's tile layers while it is paused, then keep playing with the changes
  • Press 0 while the debug overlay is open to edit, 0 again to play, or call levelEditor.open() and close()
  • Edits the Tiled map the game loaded, saves it back as Tiled JSON, and autosaves every change
  • Debug builds only, the release build has stubs for its names in engineRelease.js and none of its code

Classes

Functions

Members

Typedefs

Functions

setLevelEditor(editor)engineEditor.js:301

Make a level editor of the game's own the one in use: an instance of a class that extends LevelEditor, with the game's hooks as its methods; set it before the editor opens

editor LevelEditor

Members

The level editor, levelEditor.open() to edit the level, levelEditor.close() to play on with the changes

Typedefs

EditorEdit2D : ObjectengineEditor.js:61

The 2D level editor's edit functions, levelEditor.edit2D

map Object|undefined

The Tiled map of the selected layer

layer TileLayer|undefined

The selected tile layer, undefined on an object layer

objects Array<Object>

A copy of the selected object layer's objects, as Tiled has them

hover Vector2|undefined

The cell under the mouse on the selected tile layer

selection Set<number>

The selected objects' ids

paint function

Set a cell of the selected tile layer to a tile index, -1 erases, with a direction 0 to 3 and a mirror; false off the layer or with none

changeObjects function

Edit a copy of the selected object layer's objects; false when nothing changed

strokeEnd function

End the edit: one undo step, and the autosave

strokeCancel function

Take the edit being made back

bulk function

Many paints with one redraw a layer

undo function

Undo, or redo with true

toJSON function

The map as the text Save writes

EditorEdit3D : ObjectengineEditor.js:80

The 3D level editor's edit functions, levelEditor.edit3D; a position, a rotation and a scale are Vector3, the rotation in degrees

level Object|undefined

The level object being edited

objects Array<Object>

Its objects, the list in the level: read it, edit through change

selection Set<number>

The selected objects' ids

selected function

The selected objects

made function

What the game made for an object's id

change function

Edit a copy of the object list; false when nothing changed

changePart function

Edit the level's scene, voxels, terrain or prefabs block

strokeEnd function

End the edit: one undo step, and the autosave

strokeCancel function

Take the edit being made back

place function

Add an object of a type at a position, selected; its id, undefined when there is no such type or the level can not be edited

setTransform function

Write a place, a rotation and a scale on an object of the list given to change; one left out is kept

setProperty function

Write a property on an object of the list given to change, left out of the file when it is the type's default

pos function

An object's position

rotation function

Its rotation, in degrees

scale function

Its scale

mousePoint function

Where the mouse is on the level or the ground, undefined over the panel

undo function

Undo, or redo with true

toJSON function

The level as the text Save writes

EditorPlayFromCallback(pos)engineEditor.js:15
pos any

Where to start playing, a Vector2 from the 2D editor and a Vector3 from the 3D one

EditorRestartCallback()engineEditor.js:21
EditorTileCallback(layer, pos, tile)engineEditor.js:26
layer TileLayer

The layer painted

pos Vector2

The cell's position in the layer

tile number|undefined

The tile painted, undefined when erased

EditorTool : ObjectengineEditor.js:47

A tool of the game's own for the level editor, see LevelEditor.addTool; P is the type of its pos, as EditorToolAt has it

key string optional

The key that picks it, as addKey spells one

hint string optional

The hint line while it is on

onPress function optional

The left button went down in the level; returning false says the press was not the tool's

onDrag function optional

Each frame it is held

onRelease function optional

It was let go

onDraw function optional

Each frame the tool is on, to draw its cursor or preview

EditorToolAt : ObjectengineEditor.js:34

What the level editor gives the callbacks of a tool of the game's own; P is the type of pos, a Vector2 for a 2D tool, the default, and Vector3|undefined for a 3D one

pos P

Where the mouse is in the level: a Vector2 in the 2D editor; in the 3D one a Vector3 on the level or the ground, undefined when the mouse is over the panel

cell Vector2|undefined

2D: the tile cell under the mouse on the selected tile layer

ray Ray3D|undefined

3D: the mouse's Ray3D

shift boolean

Is Shift held

ctrl boolean

Is Ctrl held