class

GSDL::TileMap

Inherits Reference < Object

Constants

ALL_FLIP_FLAGS = (FLIPPED_HORIZONTALLY_FLAG | FLIPPED_VERTICALLY_FLAG) | FLIPPED_DIAGONALLY_FLAG
FLIPPED_DIAGONALLY_FLAG = 536870912_u32
FLIPPED_HORIZONTALLY_FLAG = 2147483648_u32

Bits on the far end of the 32-bit global tile ID are used for tile flags

FLIPPED_VERTICALLY_FLAG = 1073741824_u32

Constructors

from_tiled_file(filepath : String) : TileMap
Source
from_tiled_json(json : JSON::Any) : TileMap
Source
from_tiled_tmx(xml_str : String) : TileMap
Source
new(tile_width : Int32, tile_height : Int32)
Source

Class methods

find_tileset_and_local_id(global_gid_with_flags : UInt32, tilesets : Hash(String, Tileset)) : TileInfo | Nil

Translates a global_gid into a Tileset and its local_tile_id

Source
from_tiled_data(data : Bytes)
Source

Instance methods

add_tileset(key : String, tileset : Tileset)

Adds a tileset to the map with a given key

Source
draw(draw : Draw)

Draws the tilemap

Source
draw_layer(draw : Draw, layer_name : String)

Draws a specific layer

Source
find_tileset_and_local_id(global_gid_with_flags : UInt32) : TileInfo | Nil
Source
get_layer(name : String) : MapLayer | Nil

Returns a layer by name

Source
get_object_by_name(name : String) : TileObject | Nil

Returns an object by name

Source
get_objects_at(px : Float32, py : Float32) : Array(TileObject)
Source
get_objects_by_property(key : String, value : JSON::Any) : Array(TileObject)

Returns objects with a specific property

Source
get_objects_by_type(type : String) : Array(TileObject)

Returns objects of a specific type (or class)

Source
get_objects_in(rect : FRect) : Array(TileObject)
Source
height
Source
layers

Collection of MapLayers (TileLayer or ObjectGroup)

Source
layers=(layers : Array(MapLayer))

Collection of MapLayers (TileLayer or ObjectGroup)

Source
load_map_data(data : Array(Array(Int32)))

Loads map data from a simple 2D array for demonstration

Source
map_height_tiles
Source
map_height_tiles=(map_height_tiles : Int32)
Source
map_width_tiles
Source
map_width_tiles=(map_width_tiles : Int32)
Source
objects

Returns all objects across all object layers

Source
set_layer_visibility(name : String, visible : Bool)

Sets layer visibility

Source
solid_at?(x : Int32, y : Int32) : Bool
Source
solid_down?(x : Num, y : Num, width : Num, height : Num) : Bool

Checks for solid tiles directly below the bounding box

Source
solid_left?(x : Num, y : Num, width : Num, height : Num) : Bool

Checks for solid tiles directly to the left of the bounding box

Source
solid_right?(x : Num, y : Num, width : Num, height : Num) : Bool

Checks for solid tiles directly to the right of the bounding box

Source
solid_up?(x : Num, y : Num, width : Num, height : Num) : Bool

Checks for solid tiles directly above the bounding box

Source
tile_at(x : Int32, y : Int32) : TileInfo | Nil
Source
tile_height
Source
tile_height=(tile_height : Int32)
Source
tile_width
Source
tile_width=(tile_width : Int32)
Source
tiled_tilesets
Source
tiled_tilesets=(tiled_tilesets : Array(JSON::Any))
Source
tilesets

Map of tileset key to Tileset object

Source
tilesets=(tilesets : Hash(String, Tileset))

Map of tileset key to Tileset object

Source
update(dt : Float32)
Source
width
Source
z_index
Source
z_index=(z_index : Int32)
Source

Nested types