summaryrefslogtreecommitdiff
path: root/scene/2d/parallax_layer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d/parallax_layer.cpp')
-rw-r--r--scene/2d/parallax_layer.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp
index 0e83b9aaae..4b62d70648 100644
--- a/scene/2d/parallax_layer.cpp
+++ b/scene/2d/parallax_layer.cpp
@@ -28,10 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "parallax_layer.h"
+
+#include "engine.h"
#include "parallax_background.h"
void ParallaxLayer::set_motion_scale(const Size2 &p_scale) {
+ if (!get_parent())
+ return;
+
motion_scale = p_scale;
ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
@@ -49,6 +54,9 @@ Size2 ParallaxLayer::get_motion_scale() const {
void ParallaxLayer::set_motion_offset(const Size2 &p_offset) {
+ if (!get_parent())
+ return;
+
motion_offset = p_offset;
ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>();
@@ -111,7 +119,7 @@ void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, float p_sc
if (!is_inside_tree())
return;
- if (get_tree()->is_editor_hint())
+ if (Engine::get_singleton()->is_editor_hint())
return;
Point2 new_ofs = ((orig_offset + p_offset) * motion_scale) * p_scale + motion_offset;