Skip to content

Commit

Permalink
feat:star wrath leave animation update
Browse files Browse the repository at this point in the history
  • Loading branch information
limuy2022 committed Jul 12, 2024
1 parent f4b4704 commit e18adf4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scenes/weapons/star_wrath/star_wrath.gd
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
extends StarWrath

@export var star_wrath_origin: PackedScene
var operation_idx = 0
var operations = [func(): self.fall_star_process(), func(): self.leave()]
@onready var animation_player = $AnimationPlayer
@onready var star_wrath = $StarWrath

var operations = [func(): self.fall_star_process(), func(): self.leave()]
var operation_idx = 0


func next_operation():
if operation_idx >= operations.size():
Expand All @@ -28,6 +27,7 @@ func leave():
await self.get_tree().create_timer(0.3).timeout
var tween = create_tween()
tween.tween_property(star_wrath, "global_position", Vector2(-100.0, -100), 2)
tween.tween_callback($"..".general_hide.bind())
next_operation()


Expand Down
1 change: 1 addition & 0 deletions scenes/weapons/star_wrath/star_wrath.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
shader = ExtResource("2_xksic")
shader_parameter/color_end = Vector4(0.5, 0, 0.5, 0.1)
shader_parameter/color_start = Vector4(0.5, 0, 0.5, 0.5)
shader_parameter/alpha_bias = 0.0

[sub_resource type="RectangleShape2D" id="RectangleShape2D_qm46a"]
size = Vector2(28.6936, 31.8029)
Expand Down
15 changes: 15 additions & 0 deletions scenes/weapons/star_wrath/star_wrath_root.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
extends Node

signal attack_finished
var tween
@onready var star_wrath = $StarWrath
@onready var bg = $Bg

Expand All @@ -23,6 +24,20 @@ func show():
bg.show()


func general_hide():
tween = create_tween().set_loops()
tween.tween_callback(self.general_hide_interal.bind()).set_delay(0.01)

Check warning on line 29 in scenes/weapons/star_wrath/star_wrath_root.gd

View workflow job for this annotation

GitHub Actions / Typos

"interal" should be "internal" or "interval" or "integral".


func general_hide_interal():

Check warning on line 32 in scenes/weapons/star_wrath/star_wrath_root.gd

View workflow job for this annotation

GitHub Actions / Typos

"interal" should be "internal" or "interval" or "integral".
var tmp = bg.material.get_shader_parameter("alpha_bias")
if tmp >= 0.9:
tween.kill()
bg.hide()
star_wrath.hide()
bg.material.set_shader_parameter("alpha_bias", tmp + 0.01)


func start():
show()
star_wrath.start()
2 changes: 2 additions & 0 deletions shaders/virtual.gdshader
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ shader_type canvas_item;

uniform vec4 color_end;
uniform vec4 color_start;
uniform float alpha_bias = 0;

void vertex() {
// Called for every vertex the material is visible on.
Expand All @@ -15,6 +16,7 @@ void fragment() {
vec4 gradient_color = color_start + (color_end - color_start) * screen_coords.y * 3.6;
// 设置最终颜色
COLOR = gradient_color;
COLOR.a -= alpha_bias;
}

//void light() {
Expand Down

0 comments on commit e18adf4

Please sign in to comment.