diff --git a/project.godot b/project.godot index fe34de2e..b93b79ff 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="Funk Engine" -run/main_scene="res://scenes/BattleDirector/test_battle_scene.tscn" +run/main_scene="res://scenes/TestTransition/testTransition.tscn" config/features=PackedStringArray("4.3", "C#", "Forward Plus") config/icon="res://icon.svg" diff --git a/scenes/BattleDirector/test_battle_scene.tscn b/scenes/BattleDirector/test_battle_scene.tscn index 4f58a69d..37abc244 100644 --- a/scenes/BattleDirector/test_battle_scene.tscn +++ b/scenes/BattleDirector/test_battle_scene.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://b0mrgr7h0ty1y"] +[gd_scene load_steps=10 format=3 uid="uid://b0mrgr7h0ty1y"] [ext_resource type="Script" path="res://scenes/BattleDirector/scripts/BattleDirector.cs" id="1_cwqqr"] [ext_resource type="PackedScene" uid="uid://dfevfib11kou1" path="res://scenes/ChartViewport/ChartViewport.tscn" id="2_cupb3"] @@ -6,6 +6,7 @@ [ext_resource type="Texture2D" uid="uid://ci0g72j8q4ec2" path="res://scenes/BattleDirector/assets/CoolBG.jpg" id="4_13o87"] [ext_resource type="PackedScene" uid="uid://duhiilcv4tat3" path="res://scenes/BattleDirector/NotePlacementBar.tscn" id="7_3ko4g"] [ext_resource type="AudioStream" uid="uid://cv6lqjj6lu36h" path="res://Audio/335571__magntron__gamemusic_120bpm.mp3" id="8_caqms"] +[ext_resource type="Script" path="res://scripts/SceneChange.cs" id="9_bxa6e"] [node name="ProtoBattleDirector" type="Node2D" node_paths=PackedStringArray("CM", "NotePlacementBar", "CD", "Audio")] script = ExtResource("1_cwqqr") @@ -48,6 +49,20 @@ offset_top = 164.0 offset_right = 16.0 offset_bottom = 164.0 +[node name="Control" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="Button" type="Button" parent="Control"] +layout_mode = 0 +offset_right = 8.0 +offset_bottom = 8.0 +text = "Return to Title" +script = ExtResource("9_bxa6e") +ScenePath = "res://scenes/TestTransition/testTransition.tscn" + [node name="TempRelicList" type="Label" parent="."] offset_left = 564.0 offset_top = 165.0 diff --git a/scenes/ChartViewport/ChartManager.cs b/scenes/ChartViewport/ChartManager.cs index c6fd814f..c44c3a2c 100644 --- a/scenes/ChartViewport/ChartManager.cs +++ b/scenes/ChartViewport/ChartManager.cs @@ -127,4 +127,15 @@ private NoteArrow CreateNote(ArrowType arrow, int beat = 0) newArrow.Position += Vector2.Right * newArrow.Bounds * 10; //temporary fix for notes spawning and instantly calling loop from originating at 0,0 return newArrow; } + + public override void _ExitTree() + { + GD.Print("[DEBUG] Stopping tweens before exiting the scene..."); + + foreach (var tween in GetTree().GetProcessedTweens()) + { + tween.Stop(); + GD.Print("[DEBUG] Stopped tween."); + } + } } diff --git a/scenes/TestTransition/testTransition.tscn b/scenes/TestTransition/testTransition.tscn new file mode 100644 index 00000000..6481b551 --- /dev/null +++ b/scenes/TestTransition/testTransition.tscn @@ -0,0 +1,33 @@ +[gd_scene load_steps=2 format=3 uid="uid://dbeplni2du158"] + +[ext_resource type="Script" path="res://scripts/SceneChange.cs" id="1_n6d5u"] + +[node name="Control" type="Control"] +layout_mode = 3 +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="Node2D" type="Node2D" parent="."] + +[node name="StartButton" type="Button" parent="."] +layout_mode = 0 +offset_left = 120.0 +offset_top = 56.0 +offset_right = 128.0 +offset_bottom = 64.0 +scale = Vector2(2.48, 2.48) +text = "start battle" +script = ExtResource("1_n6d5u") +ScenePath = "res://scenes/BattleDirector/test_battle_scene.tscn" + +[node name="ExitButton" type="Button" parent="."] +layout_mode = 0 +offset_left = 471.0 +offset_top = 95.0 +offset_right = 508.0 +offset_bottom = 126.0 +scale = Vector2(2.56, 2.56) +text = "exit" +script = ExtResource("1_n6d5u") +ScenePath = "exit" diff --git a/scripts/SceneChange.cs b/scripts/SceneChange.cs new file mode 100644 index 00000000..6c1db327 --- /dev/null +++ b/scripts/SceneChange.cs @@ -0,0 +1,35 @@ +using System; +using Godot; + +public partial class SceneChange : Button +{ + [Export] + public string ScenePath = ""; + + public override void _Ready() + { + Pressed += OnButtonPressed; + GD.Print($"[DEBUG] Scene Path: '{ScenePath}'"); + } + + private void OnButtonPressed() + { + //ScenePath = ScenePath.Trim('\"'); + if (ScenePath.ToLower() == "exit") + { + GD.Print("Exiting game"); + GetTree().Quit(); + return; + } + + if (string.IsNullOrEmpty(ScenePath) || !ResourceLoader.Exists(ScenePath)) + { + GD.PrintErr($"❌ Scene not found: {ScenePath}"); + GD.Print($"[DEBUG] Trying to load: '{ScenePath}'"); + return; + } + + GD.Print($"✅ Loading scene: {ScenePath}"); + GetTree().ChangeSceneToFile(ScenePath); + } +}