diff options
Diffstat (limited to 'scene/2d/parallax_layer.cpp')
-rw-r--r-- | scene/2d/parallax_layer.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/scene/2d/parallax_layer.cpp b/scene/2d/parallax_layer.cpp index 0e83b9aaae..8fe651cb5f 100644 --- a/scene/2d/parallax_layer.cpp +++ b/scene/2d/parallax_layer.cpp @@ -3,7 +3,7 @@ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ -/* http://www.godotengine.org */ +/* https://godotengine.org */ /*************************************************************************/ /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ @@ -28,14 +28,16 @@ /* 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) { motion_scale = p_scale; - ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>(); - if (is_inside_tree() && pb) { + ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent()); + if (pb && is_inside_tree()) { Vector2 ofs = pb->get_final_offset(); float scale = pb->get_scroll_scale(); set_base_offset_and_scale(ofs, scale); @@ -51,8 +53,8 @@ void ParallaxLayer::set_motion_offset(const Size2 &p_offset) { motion_offset = p_offset; - ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>(); - if (is_inside_tree() && pb) { + ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent()); + if (pb && is_inside_tree()) { Vector2 ofs = pb->get_final_offset(); float scale = pb->get_scroll_scale(); set_base_offset_and_scale(ofs, scale); @@ -66,10 +68,7 @@ Size2 ParallaxLayer::get_motion_offset() const { void ParallaxLayer::_update_mirroring() { - if (!get_parent()) - return; - - ParallaxBackground *pb = get_parent()->cast_to<ParallaxBackground>(); + ParallaxBackground *pb = Object::cast_to<ParallaxBackground>(get_parent()); if (pb) { RID c = pb->get_world_2d()->get_canvas(); @@ -111,7 +110,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; @@ -131,7 +130,7 @@ void ParallaxLayer::set_base_offset_and_scale(const Point2 &p_offset, float p_sc String ParallaxLayer::get_configuration_warning() const { - if (!get_parent() || !get_parent()->cast_to<ParallaxBackground>()) { + if (!Object::cast_to<ParallaxBackground>(get_parent())) { return TTR("ParallaxLayer node only works when set as child of a ParallaxBackground node."); } |