diff options
author | Sofox <sofoxx@gmail.com> | 2017-10-26 20:08:40 +0100 |
---|---|---|
committer | Sofox <sofoxx@gmail.com> | 2017-10-26 20:42:51 +0100 |
commit | 43cbef219b13ce9a491b353500f5d0e3dae30452 (patch) | |
tree | 580b57080430fc4b0b7b9beffeaf6e66ba7a6337 /scene/2d/camera_2d.cpp | |
parent | 2987e6ce4ffc69da5efc0903cc00ce12e72d2125 (diff) |
Overhauled the ParallaxBackground system so that it works properly regardless of the zoom of the camera.
Diffstat (limited to 'scene/2d/camera_2d.cpp')
-rw-r--r-- | scene/2d/camera_2d.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index d65a3bfe80..3164344d15 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -52,7 +52,11 @@ void Camera2D::_update_scroll() { if (viewport) { viewport->set_canvas_transform(xform); } - get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_camera_moved", xform); + + Size2 screen_size = viewport->get_visible_rect().size; + Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5) : Point2()); + + get_tree()->call_group_flags(SceneTree::GROUP_CALL_REALTIME, group_name, "_camera_moved", xform, screen_offset); }; } |