Browse Source

Tweaks ParallaxBackground to work better with zoom. Ensures a Parallax Layer with a (1,1) motion scale synchs perfectly with a regular stationary sprite that is outside the ParallaxBackground, regardless of the zoom level and movement of the camera.

Sofox 7 years ago
parent
commit
aaf6e77198
1 changed files with 1 additions and 1 deletions
  1. 1 1
      scene/2d/parallax_background.cpp

+ 1 - 1
scene/2d/parallax_background.cpp

@@ -49,8 +49,8 @@ void ParallaxBackground::_notification(int p_what) {
 
 
 void ParallaxBackground::_camera_moved(const Transform2D &p_transform) {
 void ParallaxBackground::_camera_moved(const Transform2D &p_transform) {
 
 
-	set_scroll_offset(p_transform.get_origin());
 	set_scroll_scale(p_transform.get_scale().dot(Vector2(0.5, 0.5)));
 	set_scroll_scale(p_transform.get_scale().dot(Vector2(0.5, 0.5)));
+	set_scroll_offset(p_transform.get_origin() / p_transform.get_scale());
 }
 }
 
 
 void ParallaxBackground::set_scroll_scale(float p_scale) {
 void ParallaxBackground::set_scroll_scale(float p_scale) {