Attack animation

This commit is contained in:
RealMelwei 2025-09-19 12:08:35 +02:00
parent e73b3f01ff
commit a8f92305ec
5 changed files with 91 additions and 17 deletions

View file

@ -87,6 +87,7 @@ func manage_attack(delta : float):
if handle_input:
if(Input.is_action_just_pressed("attack") and atk_timer <= 0):
attack.emit()
$AnimatedSprite2D.play("attack")
atk_timer = atk_cooldown
func manage_active(_delta : float):
@ -110,12 +111,17 @@ func manage_animation() -> void:
if(walk_dir != 0):
facing = walk_dir
anim_sprite.scale.x = - abs(anim_sprite.scale.x) * facing
if(is_on_floor()):
if(is_on_floor() and not $AnimatedSprite2D.is_playing()):
anim_sprite.play("walk")
else:
anim_sprite.stop() # Later: Jump Animation?
else :
if anim_sprite.animation == "walk":
anim_sprite.stop()
else:
if anim_sprite.animation == "walk":
anim_sprite.stop()
if not $AnimatedSprite2D.is_playing():
$AnimatedSprite2D.play("idle")
func manage_velocity(delta: float) -> void:
up_direction = (position - earth_center).normalized();
@ -155,7 +161,6 @@ func hurt(dmg: int, dir: Vector2 = Vector2.ZERO):
current_hp -= dmg
if(current_hp <= 0):
die()
inv_time = hit_invulnerability
reset_to_velocity = Vector2(-sign(earth_aligner.local_from_global(dir).x)*knockback_strength, -damage_knockup)
return true

View file

@ -1,12 +1,16 @@
[gd_scene load_steps=15 format=3 uid="uid://cmaovvr15b3qk"]
[gd_scene load_steps=19 format=3 uid="uid://cmaovvr15b3qk"]
[ext_resource type="Script" uid="uid://ddidj1uau28ck" path="res://player/player.gd" id="1_4flbx"]
[ext_resource type="Texture2D" uid="uid://c4xg25s8loxp0" path="res://player/Player_Walk/Walk 1.png" id="2_hg6s5"]
[ext_resource type="Texture2D" uid="uid://chxob4jg7qhqu" path="res://player/Player_Walk/Walk 2.png" id="3_8t03j"]
[ext_resource type="Texture2D" uid="uid://7asmyuhicfoj" path="res://player/attack_animation/Attack Animation 0.png" id="3_32hag"]
[ext_resource type="PackedScene" uid="uid://chs0u61f45nau" path="res://utils/earth_aligner.tscn" id="3_i3pqv"]
[ext_resource type="Texture2D" uid="uid://vwbnqmbol6hh" path="res://player/Player_Walk/Walk 3.png" id="4_2ieo8"]
[ext_resource type="Texture2D" uid="uid://c4klsmctmol5b" path="res://player/attack_animation/Attack Animation 1.png" id="4_tqiix"]
[ext_resource type="PackedScene" uid="uid://d3e3kuyeh6mr1" path="res://player/sword.tscn" id="4_yw30f"]
[ext_resource type="Texture2D" uid="uid://c8xmypqf63l8f" path="res://player/attack_animation/Attack Animation 2.png" id="5_e7oew"]
[ext_resource type="Texture2D" uid="uid://dawbam413fob" path="res://player/Player_Walk/Walk 4.png" id="5_ebec5"]
[ext_resource type="Texture2D" uid="uid://em1kmgnaikc1" path="res://player/attack_animation/Attack Animation 3.png" id="6_c35mf"]
[ext_resource type="Texture2D" uid="uid://y32k1koww7oy" path="res://player/Player_Walk/Walk 5.png" id="6_yllr7"]
[ext_resource type="Texture2D" uid="uid://bo7h3yc40kon3" path="res://player/Player_Walk/Walk 6.png" id="7_kb6p2"]
[ext_resource type="PackedScene" uid="uid://beotdg4etmevc" path="res://player/double_jump/double_jump_animation.tscn" id="10_8t03j"]
@ -19,6 +23,31 @@
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_32hag")
}, {
"duration": 1.0,
"texture": ExtResource("4_tqiix")
}, {
"duration": 1.0,
"texture": ExtResource("5_e7oew")
}, {
"duration": 1.0,
"texture": ExtResource("6_c35mf")
}],
"loop": false,
"name": &"attack",
"speed": 10.0
}, {
"frames": [{
"duration": 1.0,
"texture": ExtResource("2_hg6s5")
}],
"loop": true,
"name": &"idle",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": ExtResource("2_hg6s5")
}, {
"duration": 1.0,
@ -36,7 +65,7 @@ animations = [{
"duration": 1.0,
"texture": ExtResource("7_kb6p2")
}],
"loop": true,
"loop": false,
"name": &"walk",
"speed": 10.0
}]
@ -56,13 +85,12 @@ shape = SubResource("CapsuleShape2D_onrkg")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
scale = Vector2(0.37, 0.37)
sprite_frames = SubResource("SpriteFrames_dw050")
animation = &"walk"
frame_progress = 0.433977
animation = &"idle"
[node name="EarthAligner" parent="." instance=ExtResource("3_i3pqv")]
[node name="Sword" parent="." instance=ExtResource("4_yw30f")]
position = Vector2(0, -2)
scale = Vector2(1, 1)
[node name="ActiveItemCooldown" type="Timer" parent="."]
one_shot = true

BIN
player/sword.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

40
player/sword.png.import Normal file
View file

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b8aih0qr3hssc"
path="res://.godot/imported/sword.png-af572fc4a334164c3dd0648ee3ef204d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://player/sword.png"
dest_files=["res://.godot/imported/sword.png-af572fc4a334164c3dd0648ee3ef204d.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -1,9 +1,11 @@
[gd_scene load_steps=5 format=3 uid="uid://d3e3kuyeh6mr1"]
[ext_resource type="Script" uid="uid://cpyc4qqgpyx38" path="res://player/sword.gd" id="1_hv1tj"]
[ext_resource type="Texture2D" uid="uid://c4xg25s8loxp0" path="res://player/Player_Walk/Walk 1.png" id="2_hv1tj"]
[ext_resource type="Texture2D" uid="uid://b8aih0qr3hssc" path="res://player/sword.png" id="2_hv1tj"]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_e4ynd"]
radius = 18.048504
height = 36.097008
[sub_resource type="SpriteFrames" id="SpriteFrames_fahsa"]
animations = [{
@ -22,14 +24,13 @@ collision_mask = 18
script = ExtResource("1_hv1tj")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(-13, 5)
position = Vector2(-18.97778, 0.61333394)
rotation = 1.5708
scale = Vector2(-0.417, -0.985)
scale = Vector2(-0.635, -1.5)
shape = SubResource("CapsuleShape2D_e4ynd")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
visible = false
position = Vector2(-13, 5)
rotation = 1.5708
scale = Vector2(-0.185, -0.278)
modulate = Color(1, 1, 1, 0.6862745)
position = Vector2(-25.644447, 0.61333346)
scale = Vector2(-0.385, 0.231)
sprite_frames = SubResource("SpriteFrames_fahsa")