-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
KTools2202
authored and
KTools2202
committed
Jul 10, 2024
1 parent
9bf262a
commit 1de4b03
Showing
2 changed files
with
14 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
extends Control | ||
|
||
func _ready(): | ||
# Access the TextureButton node | ||
var button_node = $TextureButton # Assumes TextureButton is a child node of Control | ||
|
||
@onready var audio_player = $AudioStreamPlayer | ||
@onready var button_node = $TextureButton | ||
|
||
func _ready(): | ||
# Check if button_node is valid before connecting | ||
if button_node: | ||
# Play audio once scene is ready | ||
audio_player.play() | ||
# Connect the 'pressed' signal from TextureButton to '_on_button_pressed' method in this script | ||
button_node.connect("button_up", Callable(self, "_on_button_pressed")) | ||
else: | ||
print("TextureButton node not found or accessible.") | ||
|
||
func _on_button_pressed(): | ||
print("Button pressed!") | ||
# Debug line | ||
print("Button pressed, stopping music and changing scenes!") | ||
audio_player.stop() | ||
get_tree().change_scene_to_file("res://scenes/stages/stage1.tscn") |