Merge pull request #49409 from ekumlin/issue-32596
Enable Camera2D smoothing on limit change
This commit is contained in:
commit
8a4cb96856
|
@ -161,6 +161,8 @@
|
||||||
</member>
|
</member>
|
||||||
<member name="limit_smoothed" type="bool" setter="set_limit_smoothing_enabled" getter="is_limit_smoothing_enabled" default="false">
|
<member name="limit_smoothed" type="bool" setter="set_limit_smoothing_enabled" getter="is_limit_smoothing_enabled" default="false">
|
||||||
If [code]true[/code], the camera smoothly stops when reaches its limits.
|
If [code]true[/code], the camera smoothly stops when reaches its limits.
|
||||||
|
This has no effect if smoothing is disabled.
|
||||||
|
[b]Note:[/b] To immediately update the camera's position to be within limits without smoothing, even with this setting enabled, invoke [method reset_smoothing].
|
||||||
</member>
|
</member>
|
||||||
<member name="limit_top" type="int" setter="set_limit" getter="get_limit" default="-10000000">
|
<member name="limit_top" type="int" setter="set_limit" getter="get_limit" default="-10000000">
|
||||||
Top scroll limit in pixels. The camera stops moving when reaching this value.
|
Top scroll limit in pixels. The camera stops moving when reaching this value.
|
||||||
|
|
|
@ -178,6 +178,8 @@ Transform2D Camera2D::get_camera_transform() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect2 screen_rect(-screen_offset + ret_camera_pos, screen_size * zoom);
|
Rect2 screen_rect(-screen_offset + ret_camera_pos, screen_size * zoom);
|
||||||
|
|
||||||
|
if (!limit_smoothing_enabled) {
|
||||||
if (screen_rect.position.x < limit[SIDE_LEFT]) {
|
if (screen_rect.position.x < limit[SIDE_LEFT]) {
|
||||||
screen_rect.position.x = limit[SIDE_LEFT];
|
screen_rect.position.x = limit[SIDE_LEFT];
|
||||||
}
|
}
|
||||||
|
@ -193,6 +195,7 @@ Transform2D Camera2D::get_camera_transform() {
|
||||||
if (screen_rect.position.y < limit[SIDE_TOP]) {
|
if (screen_rect.position.y < limit[SIDE_TOP]) {
|
||||||
screen_rect.position.y = limit[SIDE_TOP];
|
screen_rect.position.y = limit[SIDE_TOP];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (offset != Vector2()) {
|
if (offset != Vector2()) {
|
||||||
screen_rect.position += offset;
|
screen_rect.position += offset;
|
||||||
|
|
Loading…
Reference in New Issue