mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
Merge pull request #2330 from FEDE0D/parallax_fix
ParallaxBackground: added option to ignore camera zoom
This commit is contained in:
commit
88b6e04cc1
@ -110,7 +110,10 @@ void ParallaxBackground::_update_scroll() {
|
||||
if (!l)
|
||||
continue;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,6 +168,18 @@ Point2 ParallaxBackground::get_limit_end() const {
|
||||
return limit_end;
|
||||
}
|
||||
|
||||
void ParallaxBackground::set_ignore_camera_zoom(bool ignore){
|
||||
|
||||
ignore_camera_zoom = ignore;
|
||||
|
||||
}
|
||||
|
||||
bool ParallaxBackground::is_ignore_camera_zoom(){
|
||||
|
||||
return ignore_camera_zoom;
|
||||
|
||||
}
|
||||
|
||||
void ParallaxBackground::_bind_methods() {
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("_camera_moved"),&ParallaxBackground::_camera_moved);
|
||||
@ -178,6 +193,8 @@ void ParallaxBackground::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("get_limit_begin"),&ParallaxBackground::get_limit_begin);
|
||||
ObjectTypeDB::bind_method(_MD("set_limit_end","ofs"),&ParallaxBackground::set_limit_end);
|
||||
ObjectTypeDB::bind_method(_MD("get_limit_end"),&ParallaxBackground::get_limit_end);
|
||||
ObjectTypeDB::bind_method(_MD("set_ignore_camera_zoom"), &ParallaxBackground::set_ignore_camera_zoom);
|
||||
ObjectTypeDB::bind_method(_MD("is_ignore_camera_zoom"), &ParallaxBackground::is_ignore_camera_zoom);
|
||||
|
||||
|
||||
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/offset"),_SCS("set_scroll_offset"),_SCS("get_scroll_offset"));
|
||||
@ -185,6 +202,7 @@ void ParallaxBackground::_bind_methods() {
|
||||
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/base_scale"),_SCS("set_scroll_base_scale"),_SCS("get_scroll_base_scale"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_begin"),_SCS("set_limit_begin"),_SCS("get_limit_begin"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"scroll/limit_end"),_SCS("set_limit_end"),_SCS("get_limit_end"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::BOOL, "scroll/ignore_camera_zoom"), _SCS("set_ignore_camera_zoom"), _SCS("is_ignore_camera_zoom"));
|
||||
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ class ParallaxBackground : public CanvasLayer {
|
||||
String group_name;
|
||||
Point2 limit_begin;
|
||||
Point2 limit_end;
|
||||
bool ignore_camera_zoom;
|
||||
|
||||
void _update_scroll();
|
||||
protected:
|
||||
@ -72,6 +73,9 @@ public:
|
||||
void set_limit_end(const Point2& p_ofs);
|
||||
Point2 get_limit_end() const;
|
||||
|
||||
void set_ignore_camera_zoom(bool ignore);
|
||||
bool is_ignore_camera_zoom();
|
||||
|
||||
ParallaxBackground();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user