19 lines
510 B
GDScript
19 lines
510 B
GDScript
extends Node2D
|
|
|
|
# Pixels / second
|
|
var speed = 100.0
|
|
# Where to loop back to
|
|
var start_position = 0.0
|
|
# When to loop
|
|
var scroll_size = 1280.0 * 2
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
start_position = position.x
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta):
|
|
position = Vector2(position.x + speed * delta, position.y)
|
|
if position.x > start_position + scroll_size:
|
|
position = Vector2(start_position, position.y)
|