update game_menu
This commit is contained in:
@@ -11,20 +11,21 @@ signal on_tab_selected(index: int)
|
||||
@export var image: Texture:
|
||||
set(value):
|
||||
image = value
|
||||
if is_inside_tree() and has_node("%TextureButton"):
|
||||
$%TextureButton.texture_normal = image
|
||||
if is_inside_tree() and has_node("%Texture"):
|
||||
$%Texture.texture = image
|
||||
|
||||
@onready var texture_button: TextureButton = $%TextureButton
|
||||
@onready var texture: TextureRect = $%Texture
|
||||
|
||||
var is_selected: bool = false
|
||||
var hover_tween: Tween
|
||||
|
||||
func _ready():
|
||||
if image != null and has_node("%TextureButton"):
|
||||
$%TextureButton.texture_normal = image
|
||||
if image != null and has_node("%Texture"):
|
||||
$%Texture.texture = image
|
||||
|
||||
func _on_texture_pressed() -> void:
|
||||
on_tab_selected.emit(index)
|
||||
func _on_gui_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
|
||||
on_tab_selected.emit(index)
|
||||
|
||||
func select():
|
||||
is_selected = true
|
||||
@@ -37,9 +38,9 @@ func deselect():
|
||||
func _move_up():
|
||||
if hover_tween: hover_tween.kill()
|
||||
hover_tween = create_tween()
|
||||
hover_tween.tween_property(texture_button, "position:y", -bob_height, duration).set_trans(Tween.TRANS_SINE)
|
||||
hover_tween.tween_property(texture, "position:y", -bob_height, duration).set_trans(Tween.TRANS_SINE)
|
||||
|
||||
func _move_down():
|
||||
if hover_tween: hover_tween.kill()
|
||||
var exit_tween = create_tween()
|
||||
exit_tween.tween_property(texture_button, "position:y", 0, duration).set_trans(Tween.TRANS_QUAD)
|
||||
exit_tween.tween_property(texture, "position:y", 0, duration).set_trans(Tween.TRANS_QUAD)
|
||||
|
||||
Reference in New Issue
Block a user