ParallaxLayer
继承: Node2D
< CanvasItem
< Node
< Object
A parallax scrolling layer to be used with ParallaxBackground
.
描述
A ParallaxLayer must be the child of a ParallaxBackground
node. Each ParallaxLayer can be set to move at different speeds relative to the camera movement or the ParallaxBackground.scroll_offset
value.
This node's children will be affected by its scroll offset.
Note: Any changes to this node's position and scale made after it enters the scene will be ignored.
属性
Vector2 | motion_mirroring |
Vector2 | motion_offset |
Vector2 | motion_scale |
PhysicsInterpolationMode | physics_interpolation_mode |
属性说明
Vector2
motion_mirroring = Vector2(0, 0)
The interval, in pixels, at which the ParallaxLayer is drawn repeatedly. Useful for creating an infinitely scrolling background. If an axis is set to 0
, the ParallaxLayer will be drawn only once along that direction.
Note: If you want the repetition to pixel-perfect match a Texture2D
displayed by a child node, you should account for any scale applied to the texture when defining this interval. For example, if you use a child Sprite2D
scaled to 0.5
to display a 600x600 texture, and want this sprite to be repeated continuously horizontally, you should set the mirroring to Vector2(300, 0)
.
Note: If the length of the viewport axis is bigger than twice the repeated axis size, it will not repeat infinitely, as the parallax layer only draws 2 instances of the layer at any given time. The visibility window is calculated from the parent ParallaxBackground
's position, not the layer's own position. So, if you use mirroring, do not change the ParallaxLayer position relative to its parent. Instead, if you need to adjust the background's position, set the CanvasLayer.offset
property in the parent ParallaxBackground
.
Note: Despite the name, the layer will not be mirrored, it will only be repeated.
Vector2
motion_offset = Vector2(0, 0)
The ParallaxLayer's offset relative to the parent ParallaxBackground's ParallaxBackground.scroll_offset
.
Vector2
motion_scale = Vector2(1, 1)
Multiplies the ParallaxLayer's motion. If an axis is set to 0
, it will not scroll.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。