【问题标题】:How to make godot infinite background scroll如何让godot无限背景滚动
【发布时间】:2020-06-22 23:28:12
【问题描述】:

在 godot 我有 ParallaxLayer

extends ParallaxLayer


var motion = Vector2(-50, 0)
var start_pos = Vector2()
var speed = -50

# Called when the node enters the scene tree for the first time.
func _ready():
    set_mirroring(motion)
    pass

func _process(delta):
    speed -= 5
    set_motion_offset(motion+Vector2(speed,0))




此代码使背景滚动但不是无限的

滚动到结尾时我不知道该怎么办

官方文档说我应该使用 set_mirroring

谁能告诉我如何使用这个功能?

或者我应该去哪里了解更多信息?

【问题讨论】:

    标签: godot


    【解决方案1】:

    镜像需要一个 Vector2 值,它是镜像“偏移”的 XY 坐标。通常,此值将是您用作背景的图像的高度或宽度(通常与窗口大小相对应),具体取决于您要镜像的方向。下面的示例代码假定窗口大小为 1080x1920,ParallaxLayer 镜像在 Y 轴上。

    extends ParallaxLayer
    
    func _ready():
        set_mirroring(motion_mirroring)
    
    func _process(delta):
        motion_mirroring = Vector2(0,1920)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-30
      • 2017-05-14
      • 1970-01-01
      • 1970-01-01
      • 2018-10-02
      • 2022-12-24
      • 2020-02-08
      相关资源
      最近更新 更多