feat(ultrasound): add UltrasoundMachine component with continuous heartbeat animation
This commit is contained in:
23
scripts/objects/ultrasound_machine.gd
Normal file
23
scripts/objects/ultrasound_machine.gd
Normal file
@@ -0,0 +1,23 @@
|
||||
## UltrasoundMachine — displays a continuous heartbeat pulse on the screen.
|
||||
class_name UltrasoundMachine extends Node2D
|
||||
|
||||
const BEAT_RISE_DURATION: float = 0.12
|
||||
const BEAT_FALL_DURATION: float = 0.12
|
||||
const BEAT_INTERVAL: float = 0.60
|
||||
const BEAT_SCALE_PEAK: Vector2 = Vector2(1.5, 1.5)
|
||||
const BEAT_SCALE_REST: Vector2 = Vector2(1.0, 1.0)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_start_heartbeat_loop()
|
||||
|
||||
|
||||
func _start_heartbeat_loop() -> void:
|
||||
var dot: Node2D = get_node_or_null("HeartbeatDot") as Node2D
|
||||
if dot == null:
|
||||
return
|
||||
var tween: Tween = create_tween()
|
||||
tween.set_loops()
|
||||
tween.tween_property(dot, "scale", BEAT_SCALE_PEAK, BEAT_RISE_DURATION)
|
||||
tween.tween_property(dot, "scale", BEAT_SCALE_REST, BEAT_FALL_DURATION)
|
||||
tween.tween_interval(BEAT_INTERVAL)
|
||||
Reference in New Issue
Block a user