mirror of
https://github.com/Steffo99/pineapple-surf.git
synced 2024-11-25 09:14:18 +00:00
Create scene manager with signals
This commit is contained in:
parent
279315e261
commit
b75fe4db19
5 changed files with 47 additions and 2 deletions
26
base/Base.gd
Normal file
26
base/Base.gd
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
var current_scn: Node = null
|
||||||
|
func change_scene(path: String):
|
||||||
|
var res: Resource = load(path)
|
||||||
|
var scn: Node = res.instantiate()
|
||||||
|
add_child(scn)
|
||||||
|
if current_scn:
|
||||||
|
current_scn.queue_free()
|
||||||
|
current_scn = scn
|
||||||
|
|
||||||
|
|
||||||
|
func start_game():
|
||||||
|
print("Starting game...")
|
||||||
|
change_scene("res://island/Island.tscn")
|
||||||
|
|
||||||
|
|
||||||
|
func goto_menu():
|
||||||
|
print("Going to the menu...")
|
||||||
|
change_scene("res://menu/Menu.tscn")
|
||||||
|
current_scn.connect("play_pressed", start_game)
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
goto_menu()
|
6
base/Base.tscn
Normal file
6
base/Base.tscn
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://vtsmwim5ayl8"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://base/Base.gd" id="1_fhviw"]
|
||||||
|
|
||||||
|
[node name="Base" type="Node"]
|
||||||
|
script = ExtResource("1_fhviw")
|
9
menu/Menu.gd
Normal file
9
menu/Menu.gd
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
extends Control
|
||||||
|
|
||||||
|
|
||||||
|
signal play_pressed()
|
||||||
|
|
||||||
|
|
||||||
|
func play():
|
||||||
|
print("Play button was pressed.")
|
||||||
|
emit_signal("play_pressed")
|
|
@ -1,6 +1,7 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://bufi0wh54u5x5"]
|
[gd_scene load_steps=4 format=3 uid="uid://bufi0wh54u5x5"]
|
||||||
|
|
||||||
[ext_resource type="Theme" uid="uid://c5a1nyqumj46j" path="res://menu/menu_theme.tres" id="1_mkxnc"]
|
[ext_resource type="Theme" uid="uid://c5a1nyqumj46j" path="res://menu/menu_theme.tres" id="1_mkxnc"]
|
||||||
|
[ext_resource type="Script" path="res://menu/Menu.gd" id="2_6amk3"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bxyximtgui1ux" path="res://assets/grass_menu_tile.png" id="2_q14jx"]
|
[ext_resource type="Texture2D" uid="uid://bxyximtgui1ux" path="res://assets/grass_menu_tile.png" id="2_q14jx"]
|
||||||
|
|
||||||
[node name="Menu" type="Control"]
|
[node name="Menu" type="Control"]
|
||||||
|
@ -13,6 +14,7 @@ grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
theme = ExtResource("1_mkxnc")
|
theme = ExtResource("1_mkxnc")
|
||||||
|
script = ExtResource("2_6amk3")
|
||||||
|
|
||||||
[node name="Panel" type="TextureRect" parent="."]
|
[node name="Panel" type="TextureRect" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
@ -72,3 +74,5 @@ layout_mode = 2
|
||||||
size_flags_vertical = 1
|
size_flags_vertical = 1
|
||||||
text = "Ludum Dare 52 - Harvest"
|
text = "Ludum Dare 52 - Harvest"
|
||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
|
|
||||||
|
[connection signal="pressed" from="Content/Control/Play" to="." method="play"]
|
||||||
|
|
|
@ -11,7 +11,7 @@ config_version=5
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="LD52"
|
config/name="LD52"
|
||||||
run/main_scene="res://menu/Menu.tscn"
|
run/main_scene="res://base/Base.tscn"
|
||||||
config/features=PackedStringArray("4.0", "GL Compatibility")
|
config/features=PackedStringArray("4.0", "GL Compatibility")
|
||||||
boot_splash/bg_color=Color(0.231373, 0.490196, 0.309804, 1)
|
boot_splash/bg_color=Color(0.231373, 0.490196, 0.309804, 1)
|
||||||
config/icon="res://assets/icon.svg"
|
config/icon="res://assets/icon.svg"
|
||||||
|
|
Loading…
Reference in a new issue