-
-
Save Kaifungamedev/ca2ffa46c6c08ddd74514b310f8d4f3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends Node2D | |
var off_screen | |
var resetpos | |
var speed = -100 | |
# Called when the node enters the scene tree for the first time. | |
func _ready(): | |
off_screen = $BackgroundEmpty.position.x * -1 | |
resetpos = $BackgroundEmpty2.position.x | |
# Called every frame. 'delta' is the elapsed time since the previous frame. | |
func _process(delta): | |
$BackgroundEmpty.position.x += speed * delta | |
$BackgroundEmpty2.position.x += speed * delta | |
if $BackgroundEmpty.position.x <= off_screen: | |
$BackgroundEmpty.position.x = resetpos | |
if $BackgroundEmpty2.position.x <= off_screen: | |
$BackgroundEmpty2.position.x = resetpos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[gd_scene load_steps=3 format=3 uid="uid://b44uioaarp3k1"] | |
[ext_resource type="Script" path="res://looping_background.gd" id="1_mf8hi"] | |
[ext_resource type="Texture2D" uid="uid://8rb07mkgsb4e" path="res://backgroundEmpty.png" id="2_bh0k8"] | |
[node name="looping_background" type="Node2D"] | |
script = ExtResource("1_mf8hi") | |
[node name="BackgroundEmpty" type="Sprite2D" parent="."] | |
position = Vector2(576, 324) | |
scale = Vector2(1.125, 0.632813) | |
texture = ExtResource("2_bh0k8") | |
[node name="BackgroundEmpty2" type="Sprite2D" parent="."] | |
position = Vector2(1728, 324) | |
scale = Vector2(1.125, 0.632813) | |
texture = ExtResource("2_bh0k8") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Engine configuration file. | |
; It's best edited using the editor UI and not directly, | |
; since the parameters that go here are not all obvious. | |
; | |
; Format: | |
; [section] ; section goes between [] | |
; param=value ; assign values to parameters | |
config_version=5 | |
[application] | |
config/name="scrolling background" | |
run/main_scene="res://looping_background.tscn" | |
config/features=PackedStringArray("4.0", "GL Compatibility") | |
config/icon="res://icon.svg" | |
[rendering] | |
renderer/rendering_method="gl_compatibility" | |
renderer/rendering_method.mobile="gl_compatibility" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment