summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-06-20 21:19:12 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-06-20 21:19:12 -0300
commitfa0d1cd27cac45534097219b52a5b7ab08e1b917 (patch)
tree1a7e1cdf6eb3a4b44793e23b8110f0649593da54 /scene/2d
parent9d4cdc6d8a04cfbd543b5385f68e61dd1b33bd94 (diff)
fix CanvasItem.get_global_transform() and CanvasItem.get_local_transform(), closes #4075
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/canvas_item.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index fa9b040d92..eb37634b24 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -1003,11 +1003,14 @@ InputEvent CanvasItem::make_input_local(const InputEvent& p_event) const {
Vector2 CanvasItem::get_global_mouse_pos() const {
- return get_viewport_transform().affine_inverse().xform(Input::get_singleton()->get_mouse_pos());
+ ERR_FAIL_COND_V(!get_viewport(),Vector2());
+ return get_canvas_transform().affine_inverse().xform( get_viewport()->get_mouse_pos() );
}
Vector2 CanvasItem::get_local_mouse_pos() const{
- return (get_viewport_transform() * get_global_transform()).affine_inverse().xform(Input::get_singleton()->get_mouse_pos());
+ ERR_FAIL_COND_V(!get_viewport(),Vector2());
+
+ return get_global_transform().affine_inverse().xform( get_global_mouse_pos() );
}