Added power-up animation

main
hecht 2 years ago
parent a4d2648f49
commit f68c5ca0a2

@ -3,6 +3,22 @@
[ext_resource type="Script" path="res://DamageLabel.gd" id="1_bkmpf"]
[ext_resource type="Texture2D" uid="uid://lrlnbd1xfm00" path="res://assets/Sprites/DamageBubble.png" id="1_hhymi"]
[sub_resource type="Animation" id="Animation_o4lh5"]
resource_name = "Fade-Out"
length = 0.3
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 1,
"values": [2, 1, 0]
}
[sub_resource type="Animation" id="Animation_su23q"]
resource_name = "Pop-Up"
length = 0.3
@ -50,22 +66,6 @@ tracks/0/keys = {
"values": [2, 2, 2, 2, 2]
}
[sub_resource type="Animation" id="Animation_o4lh5"]
resource_name = "Fade-Out"
length = 0.3
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 1,
"values": [2, 1, 0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_iir0v"]
_data = {
"Fade-Out": SubResource("Animation_o4lh5"),

@ -18,6 +18,8 @@ var stamina:int = 100
@export
var descriptor:String = "Foo"
var _material = null
var _material_counter = 0
var _actions = []
var _action_queue = []
@ -40,6 +42,8 @@ func is_animation_done() -> bool:
# Called when the node enters the scene tree for the first time.
func _ready():
_material = _animation_sprite.material;
_animation_sprite.material = null
_animation_sprite.flip_h = orientation
_animation_player.play("RESET")
@ -73,6 +77,10 @@ func _on_next_round():
_action_queue = _actions.pop_front()
_schedule_next_action()
_material_counter -= 1
if _material_counter == 0:
_animation_sprite.material = null
func _schedule_next_action():
if _animation_player.is_playing():
return
@ -98,6 +106,10 @@ func _on_animation_finished(anim_name):
print_debug("%s -> %s: _on_animation_finished -> %s!" % [Time.get_ticks_msec(), descriptor, anim_name])
_schedule_next_action()
if (anim_name == "PowerUp"):
_animation_sprite.frame = 0
_animation_sprite.material = _material
_material_counter = 3
func _on_animation_started(anim_name):
print_debug("%s -> %s: _on_animation_started -> %s!" % [Time.get_ticks_msec(), descriptor, anim_name])

@ -1,9 +1,15 @@
[gd_scene load_steps=17 format=3 uid="uid://di8on8rry21wa"]
[gd_scene load_steps=20 format=3 uid="uid://di8on8rry21wa"]
[ext_resource type="Script" path="res://Fighter.gd" id="1_k2s5v"]
[ext_resource type="Shader" path="res://assets/Shader/aura.gdshader" id="2_tgww4"]
[ext_resource type="Texture2D" uid="uid://cgshiy0fb84fy" path="res://assets/Sprites/red hood itch free Copy-Sheet.png" id="2_y8862"]
[ext_resource type="PackedScene" uid="uid://blhw157wwm02k" path="res://DamageLabel.tscn" id="3_nllc3"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_r07wr"]
shader = ExtResource("2_tgww4")
shader_parameter/aura_width = 1.0
shader_parameter/aura_color = Color(0.631373, 1, 0.827451, 1)
[sub_resource type="Animation" id="Animation_uyuin"]
resource_name = "Attack1"
length = 0.6
@ -194,6 +200,21 @@ tracks/0/keys = {
"values": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
}
[sub_resource type="Animation" id="Animation_u40bv"]
resource_name = "PowerUp"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
"update": 1,
"values": [127, 128, 129, 130, 127, 128, 129, 130, 127, 128]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_jbrqc"]
_data = {
"Attack1.1": SubResource("Animation_uyuin"),
@ -204,6 +225,7 @@ _data = {
"Attack2.3": SubResource("Animation_c0pf4"),
"Hit": SubResource("Animation_3lxjh"),
"Jump": SubResource("Animation_q3ojn"),
"PowerUp": SubResource("Animation_u40bv"),
"RESET": SubResource("Animation_hs612"),
"Shoot": SubResource("Animation_o3s7g"),
"Slide": SubResource("Animation_nqpts"),
@ -215,6 +237,7 @@ scale = Vector2(2, 2)
script = ExtResource("1_k2s5v")
[node name="Sprite2D" type="Sprite2D" parent="."]
material = SubResource("ShaderMaterial_r07wr")
texture = ExtResource("2_y8862")
hframes = 12
vframes = 11

@ -0,0 +1,37 @@
// from https://github.com/godotengine/godot-demo-projects/blob/master/2d/sprite_shaders/sprite_shaders.tscn
shader_type canvas_item;
render_mode blend_premul_alpha;
// This shader only works properly with premultiplied alpha blend mode.
uniform float aura_width = 2.0;
uniform vec4 aura_color : source_color;
void fragment() {
vec4 col = texture(TEXTURE, UV);
vec2 ps = TEXTURE_PIXEL_SIZE;
float a;
float maxa = col.a;
float mina = col.a;
a = texture(TEXTURE, UV + vec2(0.0, -aura_width) * ps).a;
maxa = max(a, maxa);
mina = min(a, mina);
a = texture(TEXTURE, UV + vec2(0.0, aura_width) * ps).a;
maxa = max(a, maxa);
mina = min(a, mina);
a = texture(TEXTURE, UV + vec2(-aura_width, 0.0) * ps).a;
maxa = max(a, maxa);
mina = min(a, mina);
a = texture(TEXTURE, UV + vec2(aura_width, 0.0) * ps).a;
maxa = max(a, maxa);
mina = min(a, mina);
col.rgb *= col.a;
COLOR = col;
COLOR.rgb += aura_color.rgb * (maxa - mina);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 72 KiB

@ -16,16 +16,20 @@ var fight_script = {
["Attack1.1", "Attack1.2", "Attack1.3"],
[],
[],
["PowerUp"],
["Attack2.1", "Attack2.2", "Attack2.3"],
[],
[],
[],
],
"rhs": [
[],
[],
[],
["Attack1.1", "Attack1.2"],
[],
[],
[],
[],
["Attack2.1"],
[],
]
@ -44,7 +48,7 @@ func _process(_delta):
func _reset():
_lhs_fighter.init(fight_script["lhs"])
_rhs_fighter.init(fight_script["rhs"])
_round_label.init(len(fight_script["lhs"] + 1))
_round_label.init(len(fight_script["lhs"])+1)
_lhs_figher_ready = true
_rhs_figher_ready = true

@ -20,6 +20,7 @@ config/icon="res://icon.svg"
window/size/viewport_width=640
window/size/viewport_height=480
window/stretch/mode="canvas_items"
[rendering]

Loading…
Cancel
Save