Godot Lecture - April
Godot 0 - Downloading Godot Application
Notes
Simple Splash Screen node tree: Control -> ColorRect -> Label
@onready var bg = $ColorRect
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var tween = get_tree().create_tween()
tween.tween_property(bg, "modulate", Color.BLACK, 0)
tween.tween_property(bg, "modulate", Color.WHITE, 1)
tween.tween_interval(1) # pause for two seconds
tween.tween_property(bg, "modulate", Color.BLACK, 1)
tween.tween_callback(change_scene)
func change_scene():
var new_scene_path = "res://title_screen.tscn" # Replace with the path to your new scene
var new_scene = load(new_scene_path) # Or use PackedScene.new() if already loaded
get_tree().change_scene_to_packed(new_scene)
Simple Title Screen node tree: Control -> TextureRect -> VBoxContainer -> Label(s)
@onready var title = $TextureRect/VBoxContainer/Label
var counter = 0
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
change_title_color(delta)
if Input.is_action_just_pressed("Jump"):
change_scene()
func change_title_color(delta):
counter += delta
if counter > 1:
counter = 0
title.label_settings.font_color = Color.from_hsv(counter,1,1)
func change_scene():
var new_scene_path = "res://game.tscn" # Replace with the path to your new scene
var new_scene = load(new_scene_path) # Or use PackedScene.new() if already loaded
get_tree().change_scene_to_packed(new_scene)
Example of for reloading current scene (restarting game)
get_tree().reload_current_scene