Skip to content
Snippets Groups Projects
Verified Commit a4b33834 authored by Louis's avatar Louis :fire:
Browse files

Support Bevy version 0.14

parent 1bedc2fd
No related branches found
No related tags found
No related merge requests found
[package] [package]
name = "micro_banimate" name = "micro_banimate"
version = "0.8.0" version = "0.9.0"
edition = "2021" edition = "2021"
license = "Apache-2.0" license = "Apache-2.0"
description = "Easily manage complex Bevy 2D sprite animations" description = "Easily manage complex Bevy 2D sprite animations"
authors = [ authors = [
"Louis Capitanchik <louis@microhacks.co.uk>" "Louis Capitanchik <louis@microhacks.co.uk>"
] ]
repository = "https://lab.lcr.gr/microhacks/micro-banimate" repository = "https://lab.lcr.gr/microhacks/micro-banimate"
...@@ -25,8 +25,8 @@ anyhow = "^1.0" ...@@ -25,8 +25,8 @@ anyhow = "^1.0"
serde = { version = "^1.0", optional = true } serde = { version = "^1.0", optional = true }
serde_json = { version = "^1.0", optional = true } serde_json = { version = "^1.0", optional = true }
toml = { version = "0.8", 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] [dev-dependencies]
bevy = "0.13" bevy = "0.14"
log = "0.4" log = "0.4"
...@@ -60,22 +60,22 @@ like this: ...@@ -60,22 +60,22 @@ like this:
```json ```json
{ {
"idle": { "idle": {
"frames": [ "frames": [
1, 1,
2, 2,
3 3
], ],
"frame_time": 250 "frame_time": 250
}, },
"shoot_right": { "shoot_right": {
"frames": [ "frames": [
34, 34,
34, 34,
34, 34,
35, 35,
36 36
], ],
"frame_time": 100 "frame_time": 100
} }
} }
``` ```
...@@ -99,6 +99,7 @@ frame_time = 100 ...@@ -99,6 +99,7 @@ frame_time = 100
| banimate version | bevy version | tilemap version | | banimate version | bevy version | tilemap version |
|---------------------|--------------|------------------------------------------| |---------------------|--------------|------------------------------------------|
| 0.9.0 | 0.14 | n/a |
| 0.8.0 | 0.13 | n/a | | 0.8.0 | 0.13 | n/a |
| 0.7.0 | 0.12 | n/a | | 0.7.0 | 0.12 | n/a |
| 0.6.0-rc.1 | 0.11 | 55c15bfa43c7a9e2adef6b70007e92d699377454 | | 0.6.0-rc.1 | 0.11 | 55c15bfa43c7a9e2adef6b70007e92d699377454 |
......
...@@ -28,7 +28,7 @@ fn load_assets( ...@@ -28,7 +28,7 @@ fn load_assets(
) { ) {
let sprites = assets.load("character.png"); let sprites = assets.load("character.png");
let atlas = atlas.add(TextureAtlasLayout::from_grid( let atlas = atlas.add(TextureAtlasLayout::from_grid(
Vec2::new(48., 48.), UVec2::new(48, 48),
10, 10,
6, 6,
None, None,
...@@ -48,12 +48,12 @@ fn spawn_assets(mut commands: Commands, assets: Res<ExampleAssets>) { ...@@ -48,12 +48,12 @@ fn spawn_assets(mut commands: Commands, assets: Res<ExampleAssets>) {
const HEIGHT: f32 = 320.0; const HEIGHT: f32 = 320.0;
commands.spawn(( commands.spawn((
SpriteSheetBundle { TextureAtlas {
layout: assets.atlas.clone_weak(),
index: 0,
},
SpriteBundle {
texture: assets.sprites.clone_weak(), texture: assets.sprites.clone_weak(),
atlas: TextureAtlas {
layout: assets.atlas.clone_weak(),
index: 0,
},
..Default::default() ..Default::default()
}, },
DirectionalAnimationBundle::with_direction( DirectionalAnimationBundle::with_direction(
......
...@@ -27,7 +27,7 @@ impl Error for LoaderError {} ...@@ -27,7 +27,7 @@ impl Error for LoaderError {}
#[cfg(feature = "json_loader")] #[cfg(feature = "json_loader")]
mod json_loader { mod json_loader {
use bevy::asset::io::Reader; use bevy::asset::io::Reader;
use bevy::asset::{AssetLoader, AsyncReadExt, BoxedFuture, LoadContext}; use bevy::asset::{AssetLoader, AsyncReadExt, LoadContext};
use crate::definitions::AnimationSet; use crate::definitions::AnimationSet;
use crate::loader::LoaderError; use crate::loader::LoaderError;
...@@ -38,21 +38,19 @@ mod json_loader { ...@@ -38,21 +38,19 @@ mod json_loader {
type Settings = (); type Settings = ();
type Error = LoaderError; type Error = LoaderError;
fn load<'a>( async fn load<'a>(
&'a self, &'a self,
reader: &'a mut Reader, reader: &'a mut Reader<'_>,
_settings: &'a Self::Settings, _settings: &'a Self::Settings,
_load_context: &'a mut LoadContext, _load_context: &'a mut LoadContext<'_>,
) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> { ) -> Result<Self::Asset, Self::Error> {
Box::pin(async move { let mut bytes = Vec::new();
let mut bytes = Vec::new(); reader
reader .read_to_end(&mut bytes)
.read_to_end(&mut bytes) .await
.await .expect("Failed to read all bytes");
.expect("Failed to read all bytes");
serde_json::from_slice(bytes.as_slice()).map_err(LoaderError::Json)
serde_json::from_slice(bytes.as_slice()).map_err(LoaderError::Json)
})
} }
fn extensions(&self) -> &[&str] { fn extensions(&self) -> &[&str] {
...@@ -65,7 +63,7 @@ mod json_loader { ...@@ -65,7 +63,7 @@ mod json_loader {
#[cfg(feature = "toml_loader")] #[cfg(feature = "toml_loader")]
mod toml_loader { mod toml_loader {
use bevy::asset::io::Reader; use bevy::asset::io::Reader;
use bevy::asset::{AssetLoader, AsyncReadExt, BoxedFuture, LoadContext}; use bevy::asset::{AssetLoader, AsyncReadExt, LoadContext};
use crate::definitions::AnimationSet; use crate::definitions::AnimationSet;
use crate::loader::LoaderError; use crate::loader::LoaderError;
...@@ -76,21 +74,19 @@ mod toml_loader { ...@@ -76,21 +74,19 @@ mod toml_loader {
type Settings = (); type Settings = ();
type Error = LoaderError; type Error = LoaderError;
fn load<'a>( async fn load<'a>(
&'a self, &'a self,
reader: &'a mut Reader, reader: &'a mut Reader<'_>,
_settings: &'a Self::Settings, _settings: &'a Self::Settings,
_load_context: &'a mut LoadContext, _load_context: &'a mut LoadContext<'_>,
) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> { ) -> Result<Self::Asset, Self::Error> {
Box::pin(async move { let mut bytes = String::new();
let mut bytes = String::new(); reader
reader .read_to_string(&mut bytes)
.read_to_string(&mut bytes) .await
.await .expect("Failed to read all bytes");
.expect("Failed to read all bytes");
toml::from_str(bytes.as_str()).map_err(LoaderError::Toml)
toml::from_str(bytes.as_str()).map_err(LoaderError::Toml)
})
} }
fn extensions(&self) -> &[&str] { fn extensions(&self) -> &[&str] {
......
...@@ -10,7 +10,7 @@ pub enum AnimationSystems { ...@@ -10,7 +10,7 @@ pub enum AnimationSystems {
SyncAnimations, 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))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AnimationCompleted { pub struct AnimationCompleted {
pub entity: Entity, pub entity: Entity,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment