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:
Juan Linietsky
2016-06-26 16:22:20 -03:00
parent 33f1204dc4
commit 282da142ae
4 changed files with 50 additions and 7 deletions

View File

@@ -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);