Universe Structure
Universe
An universe can contain more than one world. It uses an array to reference its worlds and has a variable to count the number of worlds.
object variables:
universe.worlds
array
universe.size
number
object functions:
universe:addWorld( world )
world: World object
add a world object to the last
universe:removeWorld( idx )
idx: number
remove the idx-th world
universe:getWorld( idx )
idx: number
return the idx-th world
universe:toggleBoardVisible()
toggle visible of tilebases of entire worlds
World
A world contain three layers. Each layer presents sky, ground, and underground.
module variables:
these variables should not be changed.
World.LAYER_SKY = 1
World.LAYER_GROUND = 0
World.LAYER_UNDERGROUND = -1
object variables:
world.name
string
world.sky
Layer object
world.ground
Layer object
world.underground
Layer object
object functions:
world:toggleBoardVisible()
toggle visible of tilebases for the world
Layer
A layer is a basic "chessboard" for a game. A maker can create landscape by pasting tile sprites on it. A tile is a group object which contains tilebase and sprite.
object variables:
layer.id
string, most be "sky", "ground", or "underground"
layer.world
World object
layer.tiles
2-D array
object functions:
layer:getTileAt(i, j)
i, j: number, coordinates of the layer
return specific tile
layer:setTileAt(o, i, j)
i, j: number, coordinates of the layer
add sprite from specific tile with checking and logging
layer:_setTileAt(o, i, j)
i, j: number, coordinates of the layer
add sprite from specific tile
layer:cleanAt(i, j)
i, j: number, coordinates of the layer
remove sprite from specific tile
layer:toggleBoardVisible()
toggle visible of tilebases for the layer