feat: 添加浮动文字,展示伤害和躲避
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
extends Node2D
|
||||
class_name FloatingText
|
||||
|
||||
@onready var value_label: Label = $ValueLabel
|
||||
|
||||
func setup(value: String, color) -> void:
|
||||
value_label.text = value
|
||||
modulate = color
|
||||
scale = Vector2.ZERO
|
||||
|
||||
rotation = deg_to_rad(randf_range(-10, 10))
|
||||
var random_scale := randf_range(0.8,1.6)
|
||||
|
||||
var tween := create_tween()
|
||||
|
||||
tween.parallel().tween_property(self, "scale", random_scale * Vector2.ONE, 0.4)
|
||||
tween.parallel().tween_property(self, "global_position", global_position + Vector2.UP * 15, 0.4)
|
||||
|
||||
tween .tween_interval(0.5)
|
||||
|
||||
tween.parallel().tween_property(self,"scale", Vector2.ZERO, 0.4)
|
||||
tween.parallel().tween_property(self, "modulate:a", 0.0, 0.4)
|
||||
|
||||
await tween.finished
|
||||
queue_free()
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
@@ -0,0 +1 @@
|
||||
uid://crydqt4saprcl
|
||||
@@ -0,0 +1,29 @@
|
||||
[gd_scene format=3 uid="uid://qkwyrg22h3gi"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://crydqt4saprcl" path="res://scenes/ui/floating_text/floating_text.gd" id="1_32222"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_dsam5"]
|
||||
font_size = 32
|
||||
outline_size = 10
|
||||
outline_color = Color(0.029506557, 0.029506557, 0.029506557, 1)
|
||||
|
||||
[node name="FloatingText" type="Node2D" unique_id=176496435]
|
||||
z_index = 10
|
||||
rotation = 0.13613568
|
||||
script = ExtResource("1_32222")
|
||||
|
||||
[node name="ValueLabel" type="Label" parent="." unique_id=481881550]
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -20.0
|
||||
offset_top = -19.333334
|
||||
offset_right = 20.0
|
||||
offset_bottom = 19.333334
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
text = "10"
|
||||
label_settings = SubResource("LabelSettings_dsam5")
|
||||
horizontal_alignment = 1
|
||||
Reference in New Issue
Block a user