diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/tile_map.cpp | 15 | ||||
-rw-r--r-- | scene/2d/tile_map.h | 2 |
2 files changed, 17 insertions, 0 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 18f8b5bbbb..bc2dfe1013 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1024,6 +1024,19 @@ bool TileMap::is_y_sort_mode_enabled() const { return y_sort_mode; } +Array TileMap::get_used_cells() const { + + Array a; + a.resize(tile_map.size()); + int i=0; + for (Map<PosKey,Cell>::Element *E=tile_map.front();E;E=E->next()) { + + Vector2 p (E->key().x,E->key().y); + a[i++]=p; + } + + return a; +} void TileMap::_bind_methods() { @@ -1080,6 +1093,8 @@ void TileMap::_bind_methods() { ObjectTypeDB::bind_method(_MD("clear"),&TileMap::clear); + ObjectTypeDB::bind_method(_MD("get_used_cells"),&TileMap::get_used_cells); + ObjectTypeDB::bind_method(_MD("map_to_world","mappos","ignore_half_ofs"),&TileMap::map_to_world,DEFVAL(false)); ObjectTypeDB::bind_method(_MD("world_to_map","worldpos"),&TileMap::world_to_map); diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index e02c4ee5bb..976ddfc5cf 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -171,6 +171,8 @@ private: _FORCE_INLINE_ Vector2 _map_to_world(int p_x,int p_y,bool p_ignore_ofs=false) const; + Array get_used_cells() const; + protected: |