summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/canvas_item.cpp8
-rw-r--r--scene/2d/canvas_item.h2
-rw-r--r--scene/2d/tile_map.cpp38
-rw-r--r--scene/2d/tile_map.h6
4 files changed, 48 insertions, 6 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 8c8ac835e8..f699c8f0e8 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -695,16 +695,16 @@ InputEvent CanvasItem::make_input_local(const InputEvent &p_event) const {
return p_event.xform_by((get_canvas_transform() * get_global_transform()).affine_inverse());
}
-Vector2 CanvasItem::get_global_mouse_pos() const {
+Vector2 CanvasItem::get_global_mouse_position() const {
ERR_FAIL_COND_V(!get_viewport(), Vector2());
- return get_canvas_transform().affine_inverse().xform(get_viewport()->get_mouse_pos());
+ return get_canvas_transform().affine_inverse().xform(get_viewport()->get_mouse_position());
}
Vector2 CanvasItem::get_local_mouse_pos() const {
ERR_FAIL_COND_V(!get_viewport(), Vector2());
- return get_global_transform().affine_inverse().xform(get_global_mouse_pos());
+ return get_global_transform().affine_inverse().xform(get_global_mouse_position());
}
void CanvasItem::_bind_methods() {
@@ -771,7 +771,7 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_viewport_rect"), &CanvasItem::get_viewport_rect);
ClassDB::bind_method(D_METHOD("get_canvas_transform"), &CanvasItem::get_canvas_transform);
ClassDB::bind_method(D_METHOD("get_local_mouse_pos"), &CanvasItem::get_local_mouse_pos);
- ClassDB::bind_method(D_METHOD("get_global_mouse_pos"), &CanvasItem::get_global_mouse_pos);
+ ClassDB::bind_method(D_METHOD("get_global_mouse_position"), &CanvasItem::get_global_mouse_position);
ClassDB::bind_method(D_METHOD("get_canvas"), &CanvasItem::get_canvas);
ClassDB::bind_method(D_METHOD("get_world_2d"), &CanvasItem::get_world_2d);
//ClassDB::bind_method(D_METHOD("get_viewport"),&CanvasItem::get_viewport);
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index ce72f7e0c9..72fe5b93da 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -212,7 +212,7 @@ public:
InputEvent make_input_local(const InputEvent &pevent) const;
Vector2 make_canvas_pos_local(const Vector2 &screen_point) const;
- Vector2 get_global_mouse_pos() const;
+ Vector2 get_global_mouse_position() const;
Vector2 get_local_mouse_pos() const;
void set_notify_local_transform(bool p_enable);
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 06d1e128c6..080276eb25 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -877,6 +877,26 @@ void TileMap::set_collision_mask(uint32_t p_mask) {
}
}
+void TileMap::set_collision_layer_bit(int p_bit, bool p_value) {
+
+ uint32_t layer = get_collision_layer();
+ if (p_value)
+ layer |= 1 << p_bit;
+ else
+ layer &= ~(1 << p_bit);
+ set_collision_layer(layer);
+}
+
+void TileMap::set_collision_mask_bit(int p_bit, bool p_value) {
+
+ uint32_t mask = get_collision_mask();
+ if (p_value)
+ mask |= 1 << p_bit;
+ else
+ mask &= ~(1 << p_bit);
+ set_collision_mask(mask);
+}
+
bool TileMap::get_collision_use_kinematic() const {
return use_kinematic;
@@ -928,6 +948,16 @@ uint32_t TileMap::get_collision_mask() const {
return collision_mask;
}
+bool TileMap::get_collision_layer_bit(int p_bit) const {
+
+ return get_collision_layer() & (1 << p_bit);
+}
+
+bool TileMap::get_collision_mask_bit(int p_bit) const {
+
+ return get_collision_mask() & (1 << p_bit);
+}
+
void TileMap::set_mode(Mode p_mode) {
_clear_quadrants();
@@ -1197,12 +1227,18 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_collision_use_kinematic", "use_kinematic"), &TileMap::set_collision_use_kinematic);
ClassDB::bind_method(D_METHOD("get_collision_use_kinematic"), &TileMap::get_collision_use_kinematic);
- ClassDB::bind_method(D_METHOD("set_collision_layer", "mask"), &TileMap::set_collision_layer);
+ ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &TileMap::set_collision_layer);
ClassDB::bind_method(D_METHOD("get_collision_layer"), &TileMap::get_collision_layer);
ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &TileMap::set_collision_mask);
ClassDB::bind_method(D_METHOD("get_collision_mask"), &TileMap::get_collision_mask);
+ ClassDB::bind_method(D_METHOD("set_collision_layer_bit", "bit", "value"), &TileMap::set_collision_layer_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_layer_bit", "bit"), &TileMap::get_collision_layer_bit);
+
+ ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &TileMap::set_collision_mask_bit);
+ ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &TileMap::get_collision_mask_bit);
+
ClassDB::bind_method(D_METHOD("set_collision_friction", "value"), &TileMap::set_collision_friction);
ClassDB::bind_method(D_METHOD("get_collision_friction"), &TileMap::get_collision_friction);
diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h
index 8979476aa5..3468854a61 100644
--- a/scene/2d/tile_map.h
+++ b/scene/2d/tile_map.h
@@ -233,6 +233,12 @@ public:
void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_mask() const;
+ void set_collision_layer_bit(int p_bit, bool p_value);
+ bool get_collision_layer_bit(int p_bit) const;
+
+ void set_collision_mask_bit(int p_bit, bool p_value);
+ bool get_collision_mask_bit(int p_bit) const;
+
void set_collision_use_kinematic(bool p_use_kinematic);
bool get_collision_use_kinematic() const;