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.

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

屬性

int

layer

-100 (overrides CanvasLayer)

Vector2

scroll_base_offset

Vector2(0, 0)

Vector2

scroll_base_scale

Vector2(1, 1)

bool

scroll_ignore_camera_zoom

false

Vector2

scroll_limit_begin

Vector2(0, 0)

Vector2

scroll_limit_end

Vector2(0, 0)

Vector2

scroll_offset

Vector2(0, 0)


屬性說明

Vector2 scroll_base_offset = Vector2(0, 0) 🔗

  • void set_scroll_base_offset(value: Vector2)

  • Vector2 get_scroll_base_offset()

所有 ParallaxLayer 子元素的基本位置偏移。


Vector2 scroll_base_scale = Vector2(1, 1) 🔗

  • void set_scroll_base_scale(value: Vector2)

  • Vector2 get_scroll_base_scale()

所有 ParallaxLayer 子元素的基本移動比例。


bool scroll_ignore_camera_zoom = false 🔗

  • void set_ignore_camera_zoom(value: bool)

  • bool is_ignore_camera_zoom()

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 時會自動計算,但也可用於手動管理無相機時的滾動。