Editor. LevelEditor

The level editor, open it to pause the game and edit its level, close it to play on with the changes

  • One of it, levelEditor, 0 on the debug overlay opens and closes it too
  • In release builds levelEditor is a stub that never opens, and its hooks are never called

Constructor

new LevelEditor()

Example
levelEditor.onRestart = ()=> loadLevel(); // adds a Restart button that rebuilds the level
levelEditor.onTile = (layer, pos, tile)=> layer.setCollisionData(pos, tile === ladderTile ? -1 : tile ? 1 : 0);

Members

isOpen

True while the editor is open, the game is paused under it

onPlayFrom :EditorPlayFromCallback|undefined

Type:
  • EditorPlayFromCallback | undefined
Properties
TypeDescription
function | undefined

Put the player at a world position; with it, the editor's Advanced section has Play from mouse, which starts play there, Escape at the mouse and Play at the view center

onRestart :EditorRestartCallback|undefined

Type:
  • EditorRestartCallback | undefined
Properties
TypeDescription
function | undefined

Rebuild the level from the map the editor changed, a Restart button calls it after switching to play; without one there is no Restart button

onTile :EditorTileCallback|undefined

Type:
  • EditorTileCallback | undefined
Properties
TypeDescription
EditorTileCallback | undefined

What the game does when the editor paints a tile, like setting its collision or its look the way the game does when it loads the level; without one, the collision layer gets collision 1 where there is a tile

paletteTiles :Array.<number>|undefined

Type:
  • Array.<number> | undefined
Properties
TypeDescription
Array.<number> | undefined

The tiles the palette shows, in its order, for a sheet that also holds sprites and art that are not level tiles; undefined shows every tile of the sheet

use3D :boolean|undefined

Type:
  • boolean | undefined
Properties
TypeDescription
boolean | undefined

Which level editor opens: true the 3D one, false the 2D one, undefined the 3D one when a level was loaded with level3DLoad and there is a Render3DPlugin

Methods

close()

Close the editor and end its session, the game carries on with the changes and Escape opens the debug overlay again

open()

Open the editor, pausing the game; until close(), Escape (the debug key) switches between playing and editing