![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | huahuapro |
how to:
when you hover a TextureButton, then play a sound.
thanks
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | huahuapro |
how to:
when you hover a TextureButton, then play a sound.
thanks
![]() |
Reply From: | johnygames |
Follow these steps:
TextureButton
and connect the mouse_entered
signal to your scriptAudioStreamPlayer
nodeextends Node2D
onready var audioS = $AudioStreamPlayer # or whatever you named the AudioStreamPlayer node
func _on_TextureButton_mouse_entered():
audioS.play(0.0)
Go to your AudioStreamPlayer
’s properties and choose a sound file for it to play under Stream–> Load
Go to your sound file’s Import tab and uncheck the Loop property so that it doesn’t loop when you play it.
Voila! Is this helpful? Please upvote and select this answer if it helped you.
it work!
thanks!
huahuapro | 2020-03-11 10:47
Hey there. I’m relatively new to the game creator space, so I’m a big noob here.
I’ve followed all your steps as well, and so far so good.
However, when I launch the game and I hover over my button, it crashes and gives the following error of:
ERROR: Node not found: menu/AudioStreamPlayer At:
scene/main/node.cpp:1382
Since I have the StreamPlayer in another path, I’ve set it to that said path.
I’ve been trying to fix it myself as I don’t really like asking for help, you learn more by experimenting, but this is really heating my brains, lol.
D_Zenith | 2020-04-28 14:55
Could you provide a bit more info? What is your Scene tree like? What did you set the path to? How is your code different from the snippet above?
I sounds like a path error where the engine cannot find the file it is looking for. You must have made a mistake with the path, but I cannot be sure unless you provide some more info.
johnygames | 2020-04-30 16:51
Heya, no worries now, figured it out myself. It had to do with a wrong path like you said.
Thank you for the reply anyways! Cheers!
D_Zenith | 2020-04-30 17:25