ParallaxBackground
继承: CanvasLayer
< Node
< Object
A node used to create a parallax scrolling background.
描述
A ParallaxBackground uses one or more ParallaxLayer
child nodes to create a parallax effect. Each ParallaxLayer
can move at a different speed using ParallaxLayer.motion_offset
. This creates an illusion of depth in a 2D game. If not used with a Camera2D
, you must manually calculate the scroll_offset
.
Note: Each ParallaxBackground is drawn on one specific Viewport
and cannot be shared between multiple Viewport
s, see CanvasLayer.custom_viewport
. When using multiple Viewport
s, for example in a split-screen game, you need create an individual ParallaxBackground for each Viewport
you want it to be drawn on.
属性
int | layer |
Vector2 | scroll_base_offset |
Vector2 | scroll_base_scale |
bool | scroll_ignore_camera_zoom |
Vector2 | scroll_limit_begin |
Vector2 | scroll_limit_end |
Vector2 | scroll_offset |
属性说明
Vector2
scroll_base_offset = Vector2(0, 0)
The base position offset for all ParallaxLayer
children.
Vector2
scroll_base_scale = Vector2(1, 1)
The base motion scale for all ParallaxLayer
children.
bool
scroll_ignore_camera_zoom = false
If true
, elements in ParallaxLayer
child aren't affected by the zoom level of the camera.
Vector2
scroll_limit_begin = Vector2(0, 0)
Top-left limits for scrolling to begin. If the camera is outside of this limit, the background will stop scrolling. Must be lower than scroll_limit_end
to work.
Vector2
scroll_limit_end = Vector2(0, 0)
Bottom-right limits for scrolling to end. If the camera is outside of this limit, the background will stop scrolling. Must be higher than scroll_limit_begin
to work.
Vector2
scroll_offset = Vector2(0, 0)
The ParallaxBackground's scroll value. Calculated automatically when using a Camera2D
, but can be used to manually manage scrolling when no camera is present.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。