36 lines
916 B
GDScript
36 lines
916 B
GDScript
extends Spatial
|
|
|
|
class_name ItemBalloon
|
|
|
|
const ItemScene = preload("res://scenes/item.tscn")
|
|
|
|
onready var anim_tree : AnimationTree = $"%AnimationTree"
|
|
onready var bounce_timer : Timer = $"%bounce_timer"
|
|
onready var attached_item = $"%attached_item"
|
|
|
|
var anim_playback : AnimationNodeStateMachinePlayback = null
|
|
var is_bouncing : bool = false
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
anim_playback = anim_tree["parameters/playback"]
|
|
anim_playback.travel("idle")
|
|
bounce_timer.one_shot = true
|
|
|
|
func attach_item(item : Resource):
|
|
attached_item.set_item_type(item)
|
|
|
|
func bounce():
|
|
if is_bouncing:
|
|
return
|
|
is_bouncing = true
|
|
anim_playback.travel("bounce")
|
|
bounce_timer.start(anim_playback.get_current_length())
|
|
|
|
func _on_bounce_timer_timeout():
|
|
pass
|
|
# assert(is_bouncing)
|
|
# anim_playback.start("Balloon Reset")
|
|
# anim_playback.travel("Ballon Idle")
|
|
# is_bouncing = false
|