-
Notifications
You must be signed in to change notification settings - Fork 0
Lua API: 4. RenderLayer
RenderLayer is a container that stores RenderEntities. It differs from Photoshop's layers in that you can only manipulate RenderEntity objects through it, not directly pixels.
Get the order of the layer.
Return: Integer value, which indicates the order.
Example:
layer0 = RenderManager.getLayer(0)
Runtime.log("The order of the default layer is: " .. layer0:getOrder())
Add an entity to the layer.
Parameter:
- String texturePath: The path to a loaded texture that the entity uses. Starts from "(user project folder)/assets/textures/".
Return: The instance of the created entity.
Throw:
-
EngineException: when
- the texture has failed to load
NOTE: Newly created entities are always located in the upper left corner (x=0, y=0).
Add a text entity to the layer.
Parameter:
- String content: The text content to be shown.
- String fontName (optional): The name of the loaded font to use. Default is empty string.
- Number pt (optional): Integer, which indicates the size of the font to be used. Default is 32.
Return: The instance of the created text entity.
Throw:
-
EngineException: when
- there's no loaded font with that name
- parameter 'pt' is not positive
Remove an entity from the layer.
Parameter:
- Number id: The ID of the entity.
Throw:
-
EngineException: when
- the entity with the specified ID doesn't exist
Get an entity by its ID.
Parameter:
- Number id: The ID of the entity.
Return: The entity with the specified ID.
Throw:
-
EngineException: when
- the entity with the specified ID doesn't exist
Check if an entity with the specified ID exists.
Parameter:
- Number id: The ID of the entity.
Return: true if so, false otherwise.
How many entities does the layer have?
Return: Integer indicating the total number of entities (including text entities) in the layer.
Remove all entities in the layer.