Skip to content

Commit

Permalink
feat: add special effects to terra_blade beginning animation
Browse files Browse the repository at this point in the history
  • Loading branch information
wlywlywlywly committed Aug 24, 2024
1 parent bc5eab7 commit e6954be
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 5 deletions.
4 changes: 2 additions & 2 deletions scenes/bullets/terra_blade/terra_blade_beam.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ var tween = create_tween()


func straight_move(
from: Vector2, to: Vector2, time: float, ease: Tween.EaseType, trans: Tween.TransitionType
from: Vector2, to: Vector2, time: float, ease_: Tween.EaseType, trans: Tween.TransitionType
):
rotation = (to - from).angle()
position = from
tween.tween_property(self, "position", to, time).set_ease(ease).set_trans(trans)
tween.tween_property(self, "position", to, time).set_ease(ease_).set_trans(trans)


func _on_out_screen_screen_exited():
Expand Down
23 changes: 23 additions & 0 deletions scenes/weapons/terra_blade/circle_painter.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
extends Node2D

var rad: float
var center: Vector2
var r: float


func _draw():
draw_arc(center, r, -TAU / 4, -TAU / 4 + rad, 50, Color(0, 1, 0), 30, true)


func draw(rad_: float, center_: Vector2, r_: float):
rad = rad_
center = center_
r = r_
queue_redraw()


func draw2(r_: float, rad_: float, center_: Vector2):
rad = rad_
center = center_
r = r_
queue_redraw()
16 changes: 16 additions & 0 deletions scenes/weapons/terra_blade/round_painter.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extends Node2D

var r: float
var alpha: float
var center: Vector2


func _draw():
draw_circle(center, r, Color(0, 1, 0, alpha), true, -1, true)


func draw(r_, center_):
r = r_
alpha = (270.0 - r_) / 270.0
center = center_
queue_redraw()
25 changes: 25 additions & 0 deletions scenes/weapons/terra_blade/ter87C6.tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[gd_scene load_steps=6 format=3 uid="uid://clwl2jjjehebp"]

[ext_resource type="Script" path="res://scenes/weapons/terra_blade/terra_blade.gd" id="1_1hrqx"]
[ext_resource type="Texture2D" uid="uid://cykbxj82pu7no" path="res://scenes/weapons/terra_blade/terra_blade.png" id="1_477b2"]
[ext_resource type="PackedScene" uid="uid://1megnlcsse45" path="res://scenes/bullets/terra_blade/TerraBladeBeam.tscn" id="2_yp2sf"]
[ext_resource type="Script" path="res://scenes/weapons/terra_blade/circle_painter.gd" id="4_nmed2"]
[ext_resource type="Script" path="res://scenes/weapons/terra_blade/round_painter.gd" id="5_abxlu"]

[node name="TerraBlade" type="Node"]
script = ExtResource("1_1hrqx")
terra_blade_beam = ExtResource("2_yp2sf")

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

[node name="CirclePainter" type="Node2D" parent="."]
script = ExtResource("4_nmed2")

[node name="RoundPainter" type="Node2D" parent="."]
script = ExtResource("5_abxlu")
25 changes: 25 additions & 0 deletions scenes/weapons/terra_blade/terBA15.tmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[gd_scene load_steps=6 format=3 uid="uid://clwl2jjjehebp"]

Check warning on line 1 in scenes/weapons/terra_blade/terBA15.tmp

View workflow job for this annotation

GitHub Actions / Typos

"BA" should be "BY" or "BE".

[ext_resource type="Script" path="res://scenes/weapons/terra_blade/terra_blade.gd" id="1_1hrqx"]
[ext_resource type="Texture2D" uid="uid://cykbxj82pu7no" path="res://scenes/weapons/terra_blade/terra_blade.png" id="1_477b2"]
[ext_resource type="PackedScene" uid="uid://1megnlcsse45" path="res://scenes/bullets/terra_blade/TerraBladeBeam.tscn" id="2_yp2sf"]
[ext_resource type="Script" path="res://scenes/weapons/terra_blade/circle_painter.gd" id="4_nmed2"]
[ext_resource type="Script" path="res://scenes/weapons/terra_blade/round_painter.gd" id="5_abxlu"]

[node name="TerraBlade" type="Node"]
script = ExtResource("1_1hrqx")
terra_blade_beam = ExtResource("2_yp2sf")

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

[node name="CirclePainter" type="Node2D" parent="."]
script = ExtResource("4_nmed2")

[node name="RoundPainter" type="Node2D" parent="."]
script = ExtResource("5_abxlu")
12 changes: 10 additions & 2 deletions scenes/weapons/terra_blade/terra_blade.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ func _ready():

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

# 绘制特效
tween.tween_interval(0.5)
tween.tween_method($CirclePainter.draw.bind(center, 170), 0.0, TAU, 0.6)
tween.tween_method($CirclePainter.draw2.bind(TAU, center), 170.0, 0, 0.8).set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_CUBIC)
tween.tween_callback(func(): create_tween().tween_method($RoundPainter.draw.bind(center), 0.0, 270.0, 1.2).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC))


var radial_shot = func(num: int, r: float):
var unit_rad = TAU / num
for i in range(0, num):
var beam = terra_blade_beam.instantiate()
get_parent().add_child.call_deferred(beam)
var rad = r + unit_rad * i
var to = 1500 * Vector2(cos(rad), sin(rad))
var to = 2000 * Vector2(cos(rad), sin(rad))
beam.straight_move(center, center + to, 1.5, Tween.EASE_IN, Tween.TRANS_CIRC)

tween.tween_callback(radial_shot.bind(24, 0))
Expand Down
10 changes: 9 additions & 1 deletion scenes/weapons/terra_blade/terra_blade.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[gd_scene load_steps=4 format=3 uid="uid://clwl2jjjehebp"]
[gd_scene load_steps=6 format=3 uid="uid://clwl2jjjehebp"]

[ext_resource type="Script" path="res://scenes/weapons/terra_blade/terra_blade.gd" id="1_1hrqx"]
[ext_resource type="Texture2D" uid="uid://cykbxj82pu7no" path="res://scenes/weapons/terra_blade/terra_blade.png" id="1_477b2"]
[ext_resource type="PackedScene" uid="uid://1megnlcsse45" path="res://scenes/bullets/terra_blade/TerraBladeBeam.tscn" id="2_yp2sf"]
[ext_resource type="Script" path="res://scenes/weapons/terra_blade/circle_painter.gd" id="4_nmed2"]
[ext_resource type="Script" path="res://scenes/weapons/terra_blade/round_painter.gd" id="5_abxlu"]

[node name="TerraBlade" type="Node"]
script = ExtResource("1_1hrqx")
Expand All @@ -15,3 +17,9 @@ scale = Vector2(2.3, 2.3)
texture = ExtResource("1_477b2")
offset = Vector2(12.0369, -15.4621)
metadata/_edit_group_ = true

[node name="CirclePainter" type="Node2D" parent="."]
script = ExtResource("4_nmed2")

[node name="RoundPainter" type="Node2D" parent="."]
script = ExtResource("5_abxlu")

0 comments on commit e6954be

Please sign in to comment.