2024-05-04 11:48:54 -04:00

40 lines
1.0 KiB
GDScript

extends GPUParticles2D
class_name ChargingAnim
@export var top: Vector2
@export var bottom: Vector2
@onready var effect: AnimatedSprite2D = $AnimatedSprite2D
var charging: bool = false
var timer: float = 1
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if charging:
effect.position = lerp(bottom, top, timer)
else:
effect.position = lerp(top, bottom, timer)
timer = clampf(timer + delta, 0, 1)
func charge(strength: float, element: Data.Element):
charging = true
emitting = true
process_material.orbit_velocity_min = strength / 50
process_material.orbit_velocity_max = strength / 40
process_material.scale_min = strength / 5
process_material.scale_max = strength / 4
process_material.anim_speed_min = strength / 5
process_material.anim_speed_max = strength / 4
timer = 0
func disable():
charging = false
emitting = false
timer = 0