add game scene
This commit is contained in:
12
scenes/game.gd
Normal file
12
scenes/game.gd
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
@onready var back_button: Button = $BackButtonContainer/BackButton
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
if not back_button.pressed.is_connected(_on_back_button_pressed):
|
||||||
|
back_button.pressed.connect(_on_back_button_pressed)
|
||||||
|
|
||||||
|
func _on_back_button_pressed() -> void:
|
||||||
|
AudioManager.play_ui_click()
|
||||||
|
GameManager.save_game()
|
||||||
|
GameManager.exit_to_main_menu()
|
||||||
1
scenes/game.gd.uid
Normal file
1
scenes/game.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://bvtr6yhlyuv4v
|
||||||
17
scenes/game.tscn
Normal file
17
scenes/game.tscn
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://dmwkyeq2l7u04"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://bvtr6yhlyuv4v" path="res://scenes/game.gd" id="1_uwrxv"]
|
||||||
|
|
||||||
|
[node name="Game" type="Node"]
|
||||||
|
script = ExtResource("1_uwrxv")
|
||||||
|
|
||||||
|
[node name="BackButtonContainer" type="Control" parent="."]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 0
|
||||||
|
offset_right = 40.0
|
||||||
|
offset_bottom = 40.0
|
||||||
|
|
||||||
|
[node name="BackButton" type="Button" parent="BackButtonContainer"]
|
||||||
|
offset_right = 45.0
|
||||||
|
offset_bottom = 31.0
|
||||||
|
text = "back"
|
||||||
@@ -1,4 +1,21 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
func _ready():
|
const GAME_SCENE_PATH := "res://scenes/Game.tscn"
|
||||||
pass
|
const MAIN_SCENE_PATH := "res://scenes/Main.tscn"
|
||||||
|
|
||||||
|
func start_new_game() -> void:
|
||||||
|
var packed_scene := load(GAME_SCENE_PATH)
|
||||||
|
if not packed_scene or not packed_scene is PackedScene:
|
||||||
|
push_error("Failed to load Game scene at: %s" % GAME_SCENE_PATH)
|
||||||
|
return
|
||||||
|
get_tree().change_scene_to_packed(packed_scene)
|
||||||
|
|
||||||
|
func save_game() -> void:
|
||||||
|
print("Game saved (mock)")
|
||||||
|
|
||||||
|
func exit_to_main_menu() -> void:
|
||||||
|
var packed_scene := load(MAIN_SCENE_PATH)
|
||||||
|
if not packed_scene or not packed_scene is PackedScene:
|
||||||
|
push_error("Failed to load Main scene at: %s" % MAIN_SCENE_PATH)
|
||||||
|
return
|
||||||
|
get_tree().change_scene_to_packed(packed_scene)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ func _ready():
|
|||||||
func _on_new_game_button_pressed():
|
func _on_new_game_button_pressed():
|
||||||
AudioManager.play_ui_click()
|
AudioManager.play_ui_click()
|
||||||
print("New Game pressed")
|
print("New Game pressed")
|
||||||
|
GameManager.start_new_game()
|
||||||
|
|
||||||
func _on_settings_button_pressed():
|
func _on_settings_button_pressed():
|
||||||
AudioManager.play_ui_click()
|
AudioManager.play_ui_click()
|
||||||
|
|||||||
Reference in New Issue
Block a user