diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-01-02 11:23:30 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-01-02 11:23:30 -0300 |
commit | d069c44a7fb0dc2c1939babed58fd02783856d9e (patch) | |
tree | 4322d92fff3661caecd6686ccb687c8046d7de32 /scene | |
parent | b60371074f359591493a015aeb5b4a4f0d70da16 (diff) |
-Fix TouchScreenButton to work with stretch and viewport canvas transform, closes #2286
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/canvas_item.cpp | 4 | ||||
-rw-r--r-- | scene/2d/screen_button.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 8f6df43c76..adb3574dd9 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -389,8 +389,8 @@ Matrix32 CanvasItem::get_global_transform_with_canvas() const { if (last_valid->canvas_layer) return last_valid->canvas_layer->get_transform() * xform; - else - return xform; + else if (is_inside_tree()) + return get_viewport()->get_canvas_transform() * xform; } Matrix32 CanvasItem::get_global_transform() const { diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp index 0254eb2836..d7f9b191fe 100644 --- a/scene/2d/screen_button.cpp +++ b/scene/2d/screen_button.cpp @@ -161,7 +161,7 @@ void TouchScreenButton::_input(const InputEvent& p_event) { if (finger_pressed==-1 || p_event.screen_touch.index==finger_pressed) { - Point2 coord = (get_global_transform()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y)); + Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y)); bool touched=false; if (bitmask.is_valid()) { @@ -238,7 +238,7 @@ void TouchScreenButton::_input(const InputEvent& p_event) { if (finger_pressed!=-1) return; //already fingering - Point2 coord = (get_global_transform()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y)); + Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(Point2(p_event.screen_touch.x,p_event.screen_touch.y)); bool touched=false; if (bitmask.is_valid()) { |