Skip to content

Commit

Permalink
feat: add animation for terra_blade
Browse files Browse the repository at this point in the history
  • Loading branch information
wlywlywlywly committed Aug 26, 2024
1 parent cd96f3a commit d2db25c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
13 changes: 13 additions & 0 deletions scenes/bullets/terra_blade/terra_blade_beam.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ func straight_move(
position = from
tween.tween_property(self, "position", to, time).set_ease(ease_).set_trans(trans)

func falling_move(
from: Vector2, velocity: Vector2, g: float
):
var vx = velocity.x
var vy = velocity.y
rotation = Vector2(vx, vy).angle()
var f = func(t):
var x = vx * t
var y = vy * t + g * t * t / 2.0
position = from + Vector2(x, y)
rotation -= Vector2.DOWN.angle_to(Vector2(cos(rotation), sin(rotation))) / 70
tween.tween_method(f, 0.0, 10.0, 10)


func _on_out_screen_screen_exited():
queue_free()
Expand Down
1 change: 0 additions & 1 deletion scenes/weapons/enchanted_sword/enchanted_sword.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
modulate = Color(1.5, 1.5, 1.5, 1)
z_index = 1
position = Vector2(574, 291)
rotation = -5.57284
scale = Vector2(3, 3)
texture = ExtResource("1_cwcxs")
offset = Vector2(8.27271, -8.17079)
Expand Down
35 changes: 30 additions & 5 deletions scenes/weapons/terra_blade/terra_blade.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,20 @@ var tween = create_tween()
# Called when the node enters the scene tree for the first time.
func _ready():
begin()

tween.tween_callback(func():
await get_tree().create_timer(0.2).timeout
line_call.call(Vector2(200, 200), Vector2(700,450), 10, shot_falling_beam)
)
tween.tween_property($Sprite2D, "position", Vector2(700, 450), 0.5).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC)
tween.tween_interval(10)

func line_call(from, to, num, f):
for i in range(0, num + 1):
f.call(from + (to - from) * i / num)

func begin():
$Sprite2D.position = Vector2(-500, 1000)
$Sprite2D.position = Vector2(200, 1000)
var center = Vector2(570, 200)

# 绘制特效
Expand All @@ -25,9 +36,23 @@ func begin():
get_parent().add_child.call_deferred(beam)
var rad = r + unit_rad * i
var to = 2000 * Vector2(cos(rad), sin(rad))
beam.straight_move(center, center + to, 1.5, Tween.EASE_IN, Tween.TRANS_CIRC)
beam.straight_move(center, center + to, 1.2, Tween.EASE_IN, Tween.TRANS_CIRC)

tween.tween_callback(radial_shot.bind(24, 0))
tween.tween_interval(0.2)
tween.tween_callback(radial_shot.bind(24, TAU / 48))
tween.tween_callback(func():
var t = create_tween()
t.tween_callback(radial_shot.bind(24, 0))
t.tween_interval(0.2)
t.tween_callback(radial_shot.bind(24, TAU / 48))
)
tween.tween_property($Sprite2D, "position", Vector2(200, 200), 1).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC)
tween.parallel().tween_property($Sprite2D, "rotation", TAU + (Vector2(700, 450) - Vector2(200, 200)).angle(), 1).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC).as_relative()

var seed = PI
func shot_falling_beam(center):
var beam = terra_blade_beam.instantiate()
get_parent().add_child.call_deferred(beam)
var to = 300 * Vector2(cos(seed), sin(seed))
beam.falling_move(center, to, 800)
seed = sqrt(seed * seed * seed * 114) / 2
while seed > 114:
seed /= TAU
5 changes: 4 additions & 1 deletion scenes/weapons/terra_blade/terra_blade.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ script = ExtResource("1_1hrqx")
terra_blade_beam = ExtResource("2_yp2sf")

[node name="Sprite2D" type="Sprite2D" parent="."]
modulate = Color(1.5, 1.5, 1.5, 1)
position = Vector2(527.511, 314.206)
rotation = 0.748746
scale = Vector2(2.3, 2.3)
scale = Vector2(2.5, 2.5)
texture = ExtResource("1_477b2")
offset = Vector2(12.0369, -15.4621)
metadata/_edit_group_ = true

[node name="CirclePainter" type="Node2D" parent="."]
modulate = Color(1.5, 1.5, 1.5, 1)
script = ExtResource("4_nmed2")

[node name="RoundPainter" type="Node2D" parent="."]
modulate = Color(1.5, 1.5, 1.5, 1)
script = ExtResource("5_abxlu")

0 comments on commit d2db25c

Please sign in to comment.