Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
ParallaxBackground
已棄用: Use the Parallax2D node instead.
繼承: CanvasLayer < Node < Object
用於建立視差滾動背景的節點。
說明
ParallaxBackground 使用一個或多個 ParallaxLayer 子節點來建立視差效果。每個 ParallaxLayer 可以使用 ParallaxLayer.motion_offset 以不同的速度移動。這在 2D 遊戲中可以創造一種深度錯覺。如果沒有與 Camera2D 一起使用,你必須手動計算 scroll_offset。
注意:每個 ParallaxBackground 都是在各自的 Viewport 中繪製的,無法在不同 Viewport 之間共用,見 CanvasLayer.custom_viewport。在分屏遊戲等使用多個 Viewport 的場景下,你需要每個需要繪製的 Viewport 建立單獨的 ParallaxBackground。
屬性
layer |
|
|
|
||
|
||
|
||
|
||
|
||
|
屬性說明
Vector2 scroll_base_offset = Vector2(0, 0) 🔗
所有 ParallaxLayer 子元素的基本位置偏移。
Vector2 scroll_base_scale = Vector2(1, 1) 🔗
所有 ParallaxLayer 子元素的基本移動比例。
bool scroll_ignore_camera_zoom = false 🔗
為 true 時,ParallaxLayer 子元素將不受相機縮放級別的影響。
Vector2 scroll_limit_begin = Vector2(0, 0) 🔗
開始滾動的左上角限制。如果相機超出這個限制,背景將停止滾動。必須低於 scroll_limit_end 才能工作。
Vector2 scroll_limit_end = Vector2(0, 0) 🔗
右下角限制滾動結束。如果相機超出這個限制,背景將停止滾動。必須高於 scroll_limit_begin 才能工作。
Vector2 scroll_offset = Vector2(0, 0) 🔗
視差背景的滾動值。使用 Camera2D 時會自動計算,但也可用於手動管理無相機時的滾動。