Skip to content
Download

Layers and tiles

Layers are the ones in the room Layers panel. In code, a layer is referred to by name.

Function What it does
setLayer(layer) Moves this instance to another Instances layer.
setLayerVisible(layer, visible) Shows or hides a layer.
layerVisible(layer) true if the layer is visible.
setLayerPosition(layer, x, y) Places the corner of a Background layer at (x, y) of the room.
layerX(layer), layerY(layer) The current position of the layer.
tileAt(layer, x, y) The index of the tile at that point of the Tiles layer (the first of the tileset is 0), or -1.
solidAt(x, y) true if there is a solid tile or a solid instance at that point.
self:setLayer("Frente")
setLayerVisible("Segredo", true)
setLayerPosition("Montanhas", camera.x * 0.5, 40)
if solidAt(self.x + 10, self.y) then self.flipX = not self.flipX end
  • Creating instances on a layer: spawn and spawnAtDepth, in Instances.
  • Hiding an Instances layer only stops drawing them: they keep running and colliding.
  • A hidden Tiles layer keeps blocking movement. Collision is turned off with Collides, in the editor.
  • Solid tiles count in placeFree, moveAndStop, onGround and the hit... functions.
  • Tiles do not change while the game is running.