Skip to content

Instantly share code, notes, and snippets.

@jonathanhirz
Created January 22, 2017 00:58
Show Gist options
  • Save jonathanhirz/9af0c2c54e78db97e0d46a50f9f2eb49 to your computer and use it in GitHub Desktop.
Save jonathanhirz/9af0c2c54e78db97e0d46a50f9f2eb49 to your computer and use it in GitHub Desktop.
tiled_property
static public function tiled_tile_has_property( _tilemap:TiledMap, _layer:String, _position_x:Float, _position_y:Float, _property:String ) : Bool {
var tile_coordinates = _tilemap.tile_coord(_position_x, _position_y);
if(_tilemap.inside(Std.int(tile_coordinates.x), Std.int(tile_coordinates.y))) {
var current_tile_id : Int = _tilemap.tile_at_pos(_layer, _position_x, _position_y).id - 1;
for(tiled_tileset in _tilemap.tiledmap_data.tilesets) {
for(tiled_tile in tiled_tileset.property_tiles) {
if(current_tile_id == tiled_tile.id) {
return tiled_tile.properties.exists(_property);
}
}
}
}
return false;
} //tiled_tile_has_property
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment