Methods
TiledUtils.colliderFromShape(parent: Object, data: table, x: number?, y: number?, properties: table?)
Creates a Collider based on a Tiled object shape.
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.
Arguments:
| property: string | The property string to convert. |
Returns:
| rgba: number[]? | The converted RGBA table. |
TiledUtils.parseFlagProperties(flag: string?, inverted: string?, value: string?, default_value: any, properties: table)
Returns a series of values used to determine the behavior of a flag property for a Tiled event.
Arguments:
| flag: string? | The name of the flag property. |
| inverted: string? | The name of the property used to determine if the flag should be inverted. |
| value: string? | 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.
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.
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.
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. |
TiledUtils.relativePathToAssetId(target_dir: string, asset_path: string, source_dir: string)
Attempts to resolve a relative path from a Tiled export to a valid asset id, given it points to a path inside the
target_dir of the current project.
Relative directories (..) of the asset path are resolved by starting from the source_dir, which should match the
directory the Tiled data was exported to. Exporting to a different directory and copying/moving the exported data will
likely cause this relative search to fail.
result:
| "not under prefix"
| "path outside root"
Arguments:
| target_dir: string | The Kristal folder to get the path relative to. |
| asset_path: string | The asset path from a Tiled export to resolve. |
| source_dir: string | Parent directory of the Tiled export, which the |
Returns:
| success: boolean | Whether the path resolution was successful. |
| result: string|"not under prefix"|"path outside root" | If resolution was successful, this is the asset path relative the |
| final_path: string | The final path with its extension, possibly unresolved if resolution failed. Used for debugging. |