From a55fb53cf4fc40c87083c683b4175146ba0a5df1 Mon Sep 17 00:00:00 2001 From: Cherry Date: Thu, 7 Mar 2024 12:31:59 -0500 Subject: [PATCH] new enemy animation naming convention --- pets-gd/scenes/walking_enemy.tscn | 6 +++--- pets-lib/src/world/enemy_node.rs | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pets-gd/scenes/walking_enemy.tscn b/pets-gd/scenes/walking_enemy.tscn index f356c82a..1d26787a 100644 --- a/pets-gd/scenes/walking_enemy.tscn +++ b/pets-gd/scenes/walking_enemy.tscn @@ -11,7 +11,7 @@ animations = [{ "texture": ExtResource("1_8afda") }], "loop": true, -"name": &"Idle", +"name": &"ANONNYMOUSE-Idle", "speed": 0.0 }, { "frames": [{ @@ -22,7 +22,7 @@ animations = [{ "texture": ExtResource("3_saoe0") }], "loop": true, -"name": &"Run", +"name": &"ANONNYMOUSE-Run", "speed": 6.0 }] @@ -37,7 +37,7 @@ collision_layer = 8 position = Vector2(0, -8) scale = Vector2(4, 4) sprite_frames = SubResource("SpriteFrames_hs7pi") -animation = &"Idle" +animation = &"ANONNYMOUSE-Run" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] rotation = 1.57079 diff --git a/pets-lib/src/world/enemy_node.rs b/pets-lib/src/world/enemy_node.rs index e8ffccc1..e5b4af9f 100644 --- a/pets-lib/src/world/enemy_node.rs +++ b/pets-lib/src/world/enemy_node.rs @@ -35,10 +35,11 @@ impl WalkingEnemy { let mode_str = if moving { "Run" } else { "Idle" }; // TODO uncomment when backwards sprites are added - // let dir_str = if backwards { "Back" } else { "" }; - // let anim_name = format!("{mode_str}{dir_str}"); + let dir_str = ""; // if backwards { "Back" } else { "" }; - self.sprite.set_animation(mode_str.into()); + let anim_name = format!("{}-{}{}", self.enemy_id, mode_str, dir_str); + + self.sprite.set_animation(anim_name.into()); self.sprite.set_flip_h(flipped); } }