Methods
TiledUtils.colliderFromShape(parent: Object, data: table, x: number?, y: number?, properties: table?)
Creates a Collider based on a Tiled object shape.
@param parent
— The object that the new Collider should be parented to.
@param data
— The Tiled shape data.
@param x
— An optional value defining the horizontal position of the collider.
@param y
— An optional value defining the vertical position of the collider.
@param properties
— A table defining additional properties for the collider.
@return collider
— The new Collider instance.
Arguments:
parent: Object | The object that the new Collider should be parented to. |
data: table | The Tiled shape data. |
x: number? | An optional value defining the horizontal position of the collider. |
y: number? | An optional value defining the vertical position of the collider. |
properties: table? | A table defining additional properties for the collider. |
Returns:
collider: Collider | The new Collider instance. |
TiledUtils.parseColorProperty(property: string)
Converts a Tiled color property to an RGBA color table.
@param property
— The property string to convert.
@return rgba
— The converted RGBA table.
Arguments:
property: string | The property string to convert. |
Returns:
rgba: number[]? | The converted RGBA table. |
TiledUtils.parseFlagProperties(flag: string|nil, inverted: string|nil, value: string|nil, default_value: any, properties: table)
Returns a series of values used to determine the behavior of a flag property for a Tiled event.
@param flag
— The name of the flag property.
@param inverted
— The name of the property used to determine if the flag should be inverted.
@param value
— The name of the property used to determine what the flag's value should be compared to.
@param default_value
— If a property for the value
name is not found, the value will be this instead.
@param properties
— The properties table of a Tiled event's data.
@return flag
— The name of the flag to check.
@return inverted
— Whether the result of the check should be inverted.
@return value
— The value that the flag should be compared to.
Arguments:
flag: string|nil | The name of the flag property. |
inverted: string|nil | The name of the property used to determine if the flag should be inverted. |
value: string|nil | The name of the property used to determine what the flag's value should be compared to. |
default_value: any | If a property for the |
properties: table | The properties table of a Tiled event's data. |
Returns:
flag: string | The name of the flag to check. |
inverted: boolean | Whether the result of the check should be inverted. |
value: any | The value that the flag should be compared to. |
TiledUtils.parsePropertyList(id: string, properties: table)
Returns a table with values based on Tiled properties.
The function will check for a series of numbered properties starting with the specified id
string, eg. "id1"
, followed by "id2"
, etc.
@param id
— The name the series of properties should all start with.
@param properties
— The properties table of a Tiled event's data.
@return result
— The list of property values found.
Arguments:
id: string | The name the series of properties should all start with. |
properties: table | The properties table of a Tiled event's data. |
Returns:
result: table | The list of property values found. |
TiledUtils.parsePropertyMultiList(id: string, properties: table)
Returns an array of tables with values based on Tiled properties.
The function will check for a series of layered numbered properties started with the specified id
string, eg. "id1_1"
, followed by "id1_2"
, "id2_1"
, "id2_2"
, etc.
The returned table will contain a list of tables correlating to each individual list.
For example, the first table in the returned array will contain the values for "id1_1"
and "id1_2"
, the second table will contain "id2_1"
and "id2_2"
, etc.
@param id
— The name the series of properties should all start with.
@param properties
— The properties table of a Tiled event's data.
@return result
— The list of property values found.
Arguments:
id: string | The name the series of properties should all start with. |
properties: table | The properties table of a Tiled event's data. |
Returns:
result: table | The list of property values found. |
TiledUtils.parseTileGid(id: number)
Returns the actual GID and flip flags of a tile.
@param id
— The GID of the tile.
@return gid
— The GID of the tile without the flags.
@return flip_x
— Whether the tile should be flipped horizontally.
@return flip_y
— Whether the tile should be flipped vertically.
@return flip_diag
— Whether the tile should be flipped diagonally.
Arguments:
id: number | The GID of the tile. |
Returns:
gid: integer | The GID of the tile without the flags. |
flip_x: boolean | Whether the tile should be flipped horizontally. |
flip_y: boolean | Whether the tile should be flipped vertically. |
flip_diag: boolean | Whether the tile should be flipped diagonally. |