add animations
This commit is contained in:
@@ -5,24 +5,41 @@ class_name GameMenuTab
|
||||
|
||||
signal on_tab_selected(index: int)
|
||||
|
||||
@export var bob_height: float = 100
|
||||
@export var duration: float = 0.5
|
||||
@export var index: int = 0
|
||||
@export var image: Texture:
|
||||
set(value):
|
||||
image = value
|
||||
if is_inside_tree() and has_node("%Texture"):
|
||||
$%Texture.texture_normal = image
|
||||
|
||||
var is_selected: bool = false
|
||||
if is_inside_tree() and has_node("%TextureButton"):
|
||||
$%TextureButton.texture_normal = image
|
||||
|
||||
@onready var texture_button: TextureButton = $%TextureButton
|
||||
|
||||
var is_selected: bool = false
|
||||
var hover_tween: Tween
|
||||
|
||||
func _ready():
|
||||
if image != null and has_node("%Texture"):
|
||||
$%Texture.texture_normal = image
|
||||
if image != null and has_node("%TextureButton"):
|
||||
$%TextureButton.texture_normal = image
|
||||
|
||||
func _on_texture_pressed() -> void:
|
||||
on_tab_selected.emit(index)
|
||||
|
||||
func select():
|
||||
is_selected = true
|
||||
_move_up()
|
||||
|
||||
func deselect():
|
||||
is_selected = false
|
||||
_move_down()
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user