Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

ParallaxLayer

继承: Node2D < CanvasItem < Node < Object

使用 ParallaxBackground 的视差滚动层。

描述

ParallaxLayer 必须是 ParallaxBackground 节点的子节点。每个 ParallaxLayer 都可以设置为相对于相机移动或 ParallaxBackground.scroll_offset 值。

该节点的子节点将受其滚动偏移量的影响。

注意:当该节点进入场景后,对其位置和比例的任何改变都将被忽略。

属性

Vector2

motion_mirroring

Vector2(0, 0)

Vector2

motion_offset

Vector2(0, 0)

Vector2

motion_scale

Vector2(1, 1)


属性说明

Vector2 motion_mirroring = Vector2(0, 0)

ParallaxLayer 的 Texture2D 镜像。用于创建无限滚动的背景。如果轴被设置为 0,则该 Texture2D 将不会被镜像。

如果视口轴的长度大于镜像轴的两倍大小,并不会无限重复,因为视差层在任何时候只会绘制 2 个纹理实例。

注意:虽然属性的名称如此,但实际不会对纹理进行镜像操作,而是简单地重复。


Vector2 motion_offset = Vector2(0, 0)

  • void set_motion_offset ( Vector2 value )

  • Vector2 get_motion_offset ( )

该 ParallaxLayer 的偏移量,相对于父 ParallaxBackground 的 ParallaxBackground.scroll_offset


Vector2 motion_scale = Vector2(1, 1)

  • void set_motion_scale ( Vector2 value )

  • Vector2 get_motion_scale ( )

复制视差图层的运动。如果一个轴被设置为 0,它将不会滚动。