diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ef9b889db93f0d1ea5d2692b4b4148cb7955ca5..dd4fa223deab7956aab7e80b90136ad536d40fb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.1] + +### Fixed +- Child animations would not play correct animation when parent has an override + ## [0.2.1] ### Fixed diff --git a/Cargo.toml b/Cargo.toml index f2b55b8ac6c25c0b91b98e88220ae5c4530281d0..5c780ca4a2b33c943a07c1ce9239137a5f35670e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "micro_banimate" -version = "0.3.0" +version = "0.4.0" edition = "2021" license = "Apache-2.0" description = "Easily manage complex Bevy 2D sprite animations" diff --git a/src/query.rs b/src/query.rs index c619e6396c47eafea0630c61cb696efcb2485d56..01436f072e7f7b2e904b726808a93043b92bfb71 100644 --- a/src/query.rs +++ b/src/query.rs @@ -354,12 +354,36 @@ impl<'w, 's> AnimationQuery<'w, 's> { } if let Ok(mut sprite) = self.tile_sprite.get_mut(entity) { - if let Some(current) = self - .animations - .get(handle) - .and_then(|sheet| sheet.get(&status.active_name)) - { - sprite.index = current.frames[status.active_step]; + let (directional_name, active_name, frame) = + match self.action_animation.get_mut(**parent) { + Ok(override_status) => match self.direction.get(**parent) { + Ok(dir) => { + let directional = format!("{}_{}", override_status.name, dir); + ( + directional, + override_status.name.clone(), + override_status.frame_step, + ) + } + Err(_) => ( + override_status.name.clone(), + override_status.name.clone(), + override_status.frame_step, + ), + }, + Err(_) => ( + status.active_name.clone(), + status.active_name.clone(), + status.active_step, + ), + }; + + if let Some(current) = self.animations.get(handle).and_then(|sheet| { + sheet + .get(&directional_name) + .or_else(|| sheet.get(&active_name)) + }) { + sprite.index = current.frames[frame]; } } }