How to make a button that stops when you release the music play

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Juicy-Fruit
:warning: Old Version Published before Godot 3 was released.

I have connected StreamPlayer-> TextureButton
How to make a button that stops when you release the music play

my code
`extends TextureButton
func _ready():
pass
func _on_TextureButton_pressed():
get_tree().get_root().get_node(“StreamPlayer”).play()
pass
func _on_TextureButton_released():
get_tree().get_root().get_node(“StreamPlayer”).stop()
pass

func _on_TextureButton_toggled( pressed ):
pass
`
but why this code does not work

Sorry for my English

Если нужно сделать кнопку которая перестает работать после отпускания нужно добавить в ИНСПЕКТОРЕ Click On Press и в коде добавлять не чего не надо

Juicy-Fruit | 2016-09-17 12:24

:bust_in_silhouette: Reply From: Hinsbart

If you want the button to emit a released signal, you have to enable Click On Press in the inspector.
This is not only true for TextureButtons, but buttons in general (every node that extends from BaseButton)

See the documentation

Thank you very much .It works

Juicy-Fruit | 2016-09-17 12:24