Layer (class)
Jump to navigation
Jump to search
This class provides fields/functions for managing Layers in the current level. Accessing Layers only work after the code file is initiated and after onLoad!
Static functions
| Static Layer Functions | ||
|---|---|---|
| Function | Return values | Description |
| Layer.get() | table of Layer | Returns all existing layers. |
| Layer.get(string layerName) | Layer | Returns the layer object for the layerName. If no layer object with layerName is found then nil is returned. |
| Layer(number index) | Layer | Returns the Layer object at position index in the global Layer table. Use this constructor with caution! Use Layer.get instead!! (See above) |
Instance functions
These fields and functions are part of Layer Objects and have to be called for that object. Trying to call them from the static Layer class will result in an error. Example (feel free to copy it into your lua file to see how it works):
function onStart()
local defaultLayer = Layer.get("Default")
defaultLayer:hide(true)
end
| Layer class | |||
|---|---|---|---|
| Type | Function/Field | Return values/Value type | Description |
| function | Layer:stop() | nil | Stops layer's movements. |
| function | Layer:show(boolean noSmoke) | nil | Shows the layer. If noSmoke is true, then no smoke will be displayed on showing. (LunaLua ≥v0.7) |
| function | Layer:hide(boolean noSmoke) | nil | Hides the layer. If noSmoke is true, then no smoke will be displayed on hiding. (LunaLua ≥v0.7) |
| function | Layer:toggle(boolean noSmoke) | nil | Toggles (Showing/Hiding) the layer. If noSmoke is true, then no smoke will be displayed on showing/hiding. (LunaLua ≥v0.7) |
| Field (ro) | Layer.isHidden | boolean | Returns true, if the layer is hidden. (LunaLua ≥v0.7) |
| Field (ro) | Layer.layerName | VBStr | The layer name. |
| Field | Layer.speedX | double | The x-speed of the layer. |
| Field | Layer.speedY | double | The y-speed of the layer. |