From e18adf49375e8f01c1ee1f4f959dd91f66f4b281 Mon Sep 17 00:00:00 2001 From: limuy Date: Fri, 12 Jul 2024 23:52:10 +0800 Subject: [PATCH] feat:star wrath leave animation update --- scenes/weapons/star_wrath/star_wrath.gd | 6 +++--- scenes/weapons/star_wrath/star_wrath.tscn | 1 + scenes/weapons/star_wrath/star_wrath_root.gd | 15 +++++++++++++++ shaders/virtual.gdshader | 2 ++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/scenes/weapons/star_wrath/star_wrath.gd b/scenes/weapons/star_wrath/star_wrath.gd index 1ec0a5e..db7d407 100644 --- a/scenes/weapons/star_wrath/star_wrath.gd +++ b/scenes/weapons/star_wrath/star_wrath.gd @@ -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(): @@ -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() diff --git a/scenes/weapons/star_wrath/star_wrath.tscn b/scenes/weapons/star_wrath/star_wrath.tscn index 4dab3f3..d8816ae 100644 --- a/scenes/weapons/star_wrath/star_wrath.tscn +++ b/scenes/weapons/star_wrath/star_wrath.tscn @@ -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) diff --git a/scenes/weapons/star_wrath/star_wrath_root.gd b/scenes/weapons/star_wrath/star_wrath_root.gd index 3875890..0e8b787 100644 --- a/scenes/weapons/star_wrath/star_wrath_root.gd +++ b/scenes/weapons/star_wrath/star_wrath_root.gd @@ -1,6 +1,7 @@ extends Node signal attack_finished +var tween @onready var star_wrath = $StarWrath @onready var bg = $Bg @@ -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) + + +func general_hide_interal(): + 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() diff --git a/shaders/virtual.gdshader b/shaders/virtual.gdshader index 1267f9f..02d5851 100644 --- a/shaders/virtual.gdshader +++ b/shaders/virtual.gdshader @@ -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. @@ -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() {