replace with multiplayer-coop files
This commit is contained in:
34
src/scripts/damage_number.gd
Normal file
34
src/scripts/damage_number.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
extends Label
|
||||
|
||||
@export var label: String = "1"
|
||||
|
||||
@export var color := Color(1, 1, 1, 1)
|
||||
@export var direction := Vector2.ZERO # Default direction
|
||||
var fade_delay := 0.6 # When to start fading (mid-move)
|
||||
var move_duration := 0.8 # Slash exists for 0.3 seconds
|
||||
var fade_duration := 0.2 # Time to fade out
|
||||
var stretch_amount := Vector2(1, 1.4) # How much to stretch the sprite
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
call_deferred("_initialize_damage_number")
|
||||
pass # Replace with function body.
|
||||
|
||||
func _initialize_damage_number() -> void:
|
||||
self.modulate = color
|
||||
self.text = label
|
||||
var tween = create_tween()
|
||||
var move_target = global_position + (direction.normalized() * 10) # Moves in given direction
|
||||
tween.set_trans(Tween.TRANS_CUBIC) # Smooth acceleration & deceleration
|
||||
tween.set_ease(Tween.EASE_OUT) # Fast start, then slows down
|
||||
tween.tween_property(self, "global_position", move_target, move_duration)
|
||||
|
||||
# Wait until mid-move to start fade
|
||||
await get_tree().create_timer(fade_delay).timeout
|
||||
|
||||
# Start fade-out effect
|
||||
var fade_tween = create_tween()
|
||||
fade_tween.tween_property(self, "modulate:a", 0.0, fade_duration) # Fade to transparent
|
||||
await fade_tween.finished
|
||||
queue_free()
|
||||
pass
|
||||
Reference in New Issue
Block a user