mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Added an option to ParallaxLayer to add an extra scroll offset, helps if you want to make clouds to move by themselves and animate that, for example.
This commit is contained in:
@@ -104,16 +104,18 @@ void ParallaxBackground::_update_scroll() {
|
||||
}
|
||||
ofs = -ofs;
|
||||
|
||||
final_offset=ofs;
|
||||
|
||||
for(int i=0;i<get_child_count();i++) {
|
||||
|
||||
ParallaxLayer *l=get_child(i)->cast_to<ParallaxLayer>();
|
||||
if (!l)
|
||||
continue;
|
||||
|
||||
if (ignore_camera_zoom)
|
||||
l->set_base_offset_and_scale(ofs, 1.0);
|
||||
else
|
||||
l->set_base_offset_and_scale(ofs, scale);
|
||||
if (ignore_camera_zoom)
|
||||
l->set_base_offset_and_scale(ofs, 1.0);
|
||||
else
|
||||
l->set_base_offset_and_scale(ofs, scale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +182,11 @@ bool ParallaxBackground::is_ignore_camera_zoom(){
|
||||
|
||||
}
|
||||
|
||||
Vector2 ParallaxBackground::get_final_offset() const {
|
||||
|
||||
return final_offset;
|
||||
}
|
||||
|
||||
void ParallaxBackground::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("_camera_moved"),&ParallaxBackground::_camera_moved);
|
||||
|
||||
Reference in New Issue
Block a user