38 lines
988 B
GDScript
38 lines
988 B
GDScript
extends Node2D
|
|
|
|
var hovered = false
|
|
|
|
@onready var audio_stream_player: AudioStreamPlayer = $AudioStreamPlayer
|
|
@onready var sprite_2d: Sprite2D = $Sprite2D
|
|
|
|
var tween
|
|
|
|
func _ready() -> void:
|
|
sprite_2d.scale = Vector2.ZERO
|
|
tween = create_tween()
|
|
tween.set_ease(Tween.EASE_OUT)
|
|
tween.set_trans(Tween.TRANS_BACK)
|
|
tween.tween_property(sprite_2d, "scale", Vector2.ONE, 0.25)
|
|
|
|
func _on_mouse_handler_hovered() -> void:
|
|
if hovered:
|
|
return
|
|
|
|
hovered = true
|
|
#audio_stream_player.play()
|
|
Triggerer.trigger("coin_collect_sound")
|
|
Persister.change_value("gold", 1)
|
|
|
|
if tween:
|
|
tween.kill()
|
|
|
|
tween = create_tween()
|
|
tween.tween_property(sprite_2d, "scale:x", 0, 0.125)
|
|
tween.tween_property(sprite_2d, "scale:x", 1, 0.125)
|
|
tween.tween_property(sprite_2d, "scale:x", 0, 0.125)
|
|
tween.tween_property(sprite_2d, "scale:x", 1, 0.125)
|
|
tween.tween_callback(queue_free)
|
|
|
|
var start_pos = position.y
|
|
var tween2 = create_tween()
|
|
tween2.tween_property(self, "position:y", start_pos - 5, 0.5)
|