🗺️ TILED#
Tiled is a free and open-source map editor used for creating 2D maps. This module allows you to load and render maps created with Tiled.
Note
Currently, ANTIRUINS can only display around 500 sprites at 60fps.
I suggest you export all the "static" objects as a single texture and user it in conjuction with renderObjects
local MAP = {
tileSize = 16, -- size of the tiles in the map
scale = 1, -- scale at which the map will be rendered
width = tileSize * map.width, -- calculated from the loaded map.
height = tileSize * map.height, -- calculated from the loaded map.
layers = {}
colliders = {}
}
local LAYER = {
objects = {}, -- object data
drawables = {}, -- drawable information {gid, x, y, flipX, flipY}
color = {1,1,1,1},
visible = true,
name = "layerName",
}
-- This is the tabled used for each objects in objects layers.
local OBJECTS = {
x = 0,
y = 0,
ox, = 0, -- orignal x
oy = 0, -- orignal y
w = 0,
h = 0,
name = "objectName",
type = "objectType", -- equivalent to class in Tiled
gid = 0, -- sprite id
visible = true,
properties = {},
spritesheet = nil,
color = {1,1,1,1},
scale = 1
}
Loading Maps#
Loads a Tiled map from a file and an optional spritesheet.Returns a map object.
Rendering#
Renders the specified layer. If no layer is specified, renders all layers. Renders all objects in the map. Creates a batch for optimized rendering. Renders the batch at the specified position.Layers#
Returns the layer with the specifiedname
.
Objects#
Returns the object with the specifiedname
.
Returns all objects of the specified class
. If no class is specified, returns all objects.
Adds an object to the specified layer
. If no layer is specified, adds to the first layer.
Removes the object with the specified name
.
Utilities#
Frees the resources used by the map. Returns the real GID of a tile, considering flip flags.Note
This is required to get the proper tiles ID if your flipped some sprites in Tiled. is flipped.