diff --git a/Cargo.toml b/Cargo.toml index 0f2a73df538f1ea3abd0fcd06a6b9214ad00f8a4..0bccedb820d04e5df2f978b57700034ce82ca9ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "micro_banimate" -version = "0.8.0" +version = "0.9.0" edition = "2021" license = "Apache-2.0" description = "Easily manage complex Bevy 2D sprite animations" authors = [ - "Louis Capitanchik <louis@microhacks.co.uk>" + "Louis Capitanchik <louis@microhacks.co.uk>" ] repository = "https://lab.lcr.gr/microhacks/micro-banimate" @@ -25,8 +25,8 @@ anyhow = "^1.0" serde = { version = "^1.0", optional = true } serde_json = { version = "^1.0", optional = true } toml = { version = "0.8", optional = true } -bevy = { version = "^0.13.0", default-features = false, features = ["bevy_asset", "bevy_sprite"] } +bevy = { version = "^0.14", default-features = false, features = ["bevy_asset", "bevy_sprite"] } -[dev_dependencies] -bevy = "0.13" +[dev-dependencies] +bevy = "0.14" log = "0.4" diff --git a/README.md b/README.md index decd95a238f73de5611a97dc73638f59a9792b05..8de1c8507c4aa04b2b9cef49ea984a499bb3a027 100644 --- a/README.md +++ b/README.md @@ -60,22 +60,22 @@ like this: ```json { "idle": { - "frames": [ - 1, - 2, - 3 - ], - "frame_time": 250 + "frames": [ + 1, + 2, + 3 + ], + "frame_time": 250 }, "shoot_right": { - "frames": [ - 34, - 34, - 34, - 35, - 36 - ], - "frame_time": 100 + "frames": [ + 34, + 34, + 34, + 35, + 36 + ], + "frame_time": 100 } } ``` @@ -99,6 +99,7 @@ frame_time = 100 | banimate version | bevy version | tilemap version | |---------------------|--------------|------------------------------------------| +| 0.9.0 | 0.14 | n/a | | 0.8.0 | 0.13 | n/a | | 0.7.0 | 0.12 | n/a | | 0.6.0-rc.1 | 0.11 | 55c15bfa43c7a9e2adef6b70007e92d699377454 | diff --git a/examples/basic.rs b/examples/basic.rs index 0b299fe5f5de3e184a521fbf5265fffab8d5041b..6debe1f4f903273756487a4992f6346994a27bb7 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -28,7 +28,7 @@ fn load_assets( ) { let sprites = assets.load("character.png"); let atlas = atlas.add(TextureAtlasLayout::from_grid( - Vec2::new(48., 48.), + UVec2::new(48, 48), 10, 6, None, @@ -48,12 +48,12 @@ fn spawn_assets(mut commands: Commands, assets: Res<ExampleAssets>) { const HEIGHT: f32 = 320.0; commands.spawn(( - SpriteSheetBundle { + TextureAtlas { + layout: assets.atlas.clone_weak(), + index: 0, + }, + SpriteBundle { texture: assets.sprites.clone_weak(), - atlas: TextureAtlas { - layout: assets.atlas.clone_weak(), - index: 0, - }, ..Default::default() }, DirectionalAnimationBundle::with_direction( diff --git a/src/loader.rs b/src/loader.rs index 90c65d8a5fa67809625804281391b53fc08cc02e..1484e640705748e9858600c57c7f871d1af223ee 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -27,7 +27,7 @@ impl Error for LoaderError {} #[cfg(feature = "json_loader")] mod json_loader { use bevy::asset::io::Reader; - use bevy::asset::{AssetLoader, AsyncReadExt, BoxedFuture, LoadContext}; + use bevy::asset::{AssetLoader, AsyncReadExt, LoadContext}; use crate::definitions::AnimationSet; use crate::loader::LoaderError; @@ -38,21 +38,19 @@ mod json_loader { type Settings = (); type Error = LoaderError; - fn load<'a>( + async fn load<'a>( &'a self, - reader: &'a mut Reader, + reader: &'a mut Reader<'_>, _settings: &'a Self::Settings, - _load_context: &'a mut LoadContext, - ) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> { - Box::pin(async move { - let mut bytes = Vec::new(); - reader - .read_to_end(&mut bytes) - .await - .expect("Failed to read all bytes"); - - serde_json::from_slice(bytes.as_slice()).map_err(LoaderError::Json) - }) + _load_context: &'a mut LoadContext<'_>, + ) -> Result<Self::Asset, Self::Error> { + let mut bytes = Vec::new(); + reader + .read_to_end(&mut bytes) + .await + .expect("Failed to read all bytes"); + + serde_json::from_slice(bytes.as_slice()).map_err(LoaderError::Json) } fn extensions(&self) -> &[&str] { @@ -65,7 +63,7 @@ mod json_loader { #[cfg(feature = "toml_loader")] mod toml_loader { use bevy::asset::io::Reader; - use bevy::asset::{AssetLoader, AsyncReadExt, BoxedFuture, LoadContext}; + use bevy::asset::{AssetLoader, AsyncReadExt, LoadContext}; use crate::definitions::AnimationSet; use crate::loader::LoaderError; @@ -76,21 +74,19 @@ mod toml_loader { type Settings = (); type Error = LoaderError; - fn load<'a>( + async fn load<'a>( &'a self, - reader: &'a mut Reader, + reader: &'a mut Reader<'_>, _settings: &'a Self::Settings, - _load_context: &'a mut LoadContext, - ) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> { - Box::pin(async move { - let mut bytes = String::new(); - reader - .read_to_string(&mut bytes) - .await - .expect("Failed to read all bytes"); - - toml::from_str(bytes.as_str()).map_err(LoaderError::Toml) - }) + _load_context: &'a mut LoadContext<'_>, + ) -> Result<Self::Asset, Self::Error> { + let mut bytes = String::new(); + reader + .read_to_string(&mut bytes) + .await + .expect("Failed to read all bytes"); + + toml::from_str(bytes.as_str()).map_err(LoaderError::Toml) } fn extensions(&self) -> &[&str] { diff --git a/src/systems.rs b/src/systems.rs index 4febe7fd736edfb386eb40b07093bcab9f5429f6..f9fbe1bece82e1c89eb914da52db18e22eb41caa 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -10,7 +10,7 @@ pub enum AnimationSystems { SyncAnimations, } -#[derive(Copy, Clone, Debug, Component, PartialEq, Eq, Ord, PartialOrd, Event)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Ord, PartialOrd, Event)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AnimationCompleted { pub entity: Entity,