From a634fc7a4a4a413666569d5c26562d5ee982ba3f Mon Sep 17 00:00:00 2001 From: Johan Manuel Date: Sat, 6 Feb 2016 13:27:26 +0100 Subject: [PATCH] Added get_cellv() method to TileMap --- doc/base/classes.xml | 9 +++++++++ scene/2d/tile_map.cpp | 5 +++++ scene/2d/tile_map.h | 1 + 3 files changed, 15 insertions(+) diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 13bc5a91e62..98fc4dd0859 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -36301,6 +36301,15 @@ This method controls whether the position between two cached points is interpola Return the tile index of the referenced cell. + + + + + + + Return the tile index of the cell referenced by a Vector2. + + diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 179d1f451a6..5c298e96f6c 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -694,6 +694,10 @@ void TileMap::set_cell(int p_x,int p_y,int p_tile,bool p_flip_x,bool p_flip_y,bo } +int TileMap::get_cellv(const Vector2& p_pos) const { + return get_cell(p_pos.x,p_pos.y); +} + int TileMap::get_cell(int p_x,int p_y) const { PosKey pk(p_x,p_y); @@ -1198,6 +1202,7 @@ void TileMap::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_cell","x","y","tile","flip_x","flip_y","transpose"),&TileMap::set_cell,DEFVAL(false),DEFVAL(false),DEFVAL(false)); ObjectTypeDB::bind_method(_MD("set_cellv","pos","tile","flip_x","flip_y","transpose"),&TileMap::set_cellv,DEFVAL(false),DEFVAL(false),DEFVAL(false)); ObjectTypeDB::bind_method(_MD("get_cell","x","y"),&TileMap::get_cell); + ObjectTypeDB::bind_method(_MD("get_cellv","pos"),&TileMap::get_cellv); ObjectTypeDB::bind_method(_MD("is_cell_x_flipped","x","y"),&TileMap::is_cell_x_flipped); ObjectTypeDB::bind_method(_MD("is_cell_y_flipped","x","y"),&TileMap::is_cell_y_flipped); diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 14cb52b7361..cec5ac0a1ba 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -211,6 +211,7 @@ public: bool is_cell_transposed(int p_x,int p_y) const; void set_cellv(const Vector2& p_pos,int p_tile,bool p_flip_x=false,bool p_flip_y=false,bool p_transpose=false); + int get_cellv(const Vector2& p_pos) const; Rect2 get_item_rect() const;