summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Schwarzer <me@timoschwarzer.com>2016-06-29 17:39:29 +0200
committerTimo Schwarzer <me@timoschwarzer.com>2016-06-29 17:40:29 +0200
commit6686fbc1e0458bc87909863d4a7ed018325be2d6 (patch)
tree6de10394cf37658926db4c207096be1b82bcf47a
parentf56a0435f2008cf88609124a74fcaa71ad8fb2c1 (diff)
Add reset_smoothing() for immediately fixing the camera to the destination location
-rw-r--r--scene/2d/camera_2d.cpp7
-rw-r--r--scene/2d/camera_2d.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 85256be940..71fd421b40 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -409,6 +409,12 @@ void Camera2D::force_update_scroll() {
_update_scroll();
}
+void Camera2D::reset_smoothing() {
+
+ smoothed_camera_pos = camera_pos;
+ _update_scroll();
+}
+
void Camera2D::set_follow_smoothing(float p_speed) {
@@ -544,6 +550,7 @@ void Camera2D::_bind_methods() {
ObjectTypeDB::bind_method(_MD("is_follow_smoothing_enabled"),&Camera2D::is_follow_smoothing_enabled);
ObjectTypeDB::bind_method(_MD("force_update_scroll"),&Camera2D::force_update_scroll);
+ ObjectTypeDB::bind_method(_MD("reset_smoothing"),&Camera2D::reset_smoothing);
ObjectTypeDB::bind_method(_MD("_set_old_smoothing","follow_smoothing"),&Camera2D::_set_old_smoothing);
diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h
index 22e5bc382a..8c8071e063 100644
--- a/scene/2d/camera_2d.h
+++ b/scene/2d/camera_2d.h
@@ -128,6 +128,7 @@ public:
Vector2 get_camera_pos() const;
void force_update_scroll();
+ void reset_smoothing();
Camera2D();
};