diff --git a/README.md b/README.md index a425aa4..8269e16 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ A sprite sheet animation plugin for [bevy](https://bevyengine.org) fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugin(AnimationPlugin) // <-- Add the plugin + .add_plugin(AnimationPlugin::default()) // <-- Add the plugin .add_startup_system(spawn) .run(); } diff --git a/examples/change_animation.rs b/examples/change_animation.rs index 9fa21b6..51d9dc1 100644 --- a/examples/change_animation.rs +++ b/examples/change_animation.rs @@ -16,7 +16,7 @@ fn main() { App::new() .init_resource::() .add_plugins(DefaultPlugins) - .add_plugin(AnimationPlugin) + .add_plugin(AnimationPlugin::default()) .add_startup_system_to_stage(StartupStage::PreStartup, create_animations.system()) .add_startup_system(spawn_animated_coin.system()) .add_startup_system(spawn_camera.system()) diff --git a/examples/end_of_animation_detection.rs b/examples/end_of_animation_detection.rs index b10c832..873db87 100644 --- a/examples/end_of_animation_detection.rs +++ b/examples/end_of_animation_detection.rs @@ -7,7 +7,7 @@ use benimator::*; fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugin(AnimationPlugin) + .add_plugin(AnimationPlugin::default()) .add_startup_system(spawn_animated_coin.system()) .add_startup_system(spawn_camera.system()) .add_system_to_stage(CoreStage::PostUpdate, removal_detection.system()) diff --git a/examples/ping_pong.rs b/examples/ping_pong.rs index 9cb35f8..e2922aa 100644 --- a/examples/ping_pong.rs +++ b/examples/ping_pong.rs @@ -7,7 +7,7 @@ use benimator::*; fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugin(AnimationPlugin) + .add_plugin(AnimationPlugin::default()) .add_startup_system(spawn.system()) .run(); } diff --git a/examples/readme.rs b/examples/readme.rs index 7770413..10ce623 100644 --- a/examples/readme.rs +++ b/examples/readme.rs @@ -7,7 +7,7 @@ use benimator::*; fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugin(AnimationPlugin) // <-- Add the plugin + .add_plugin(AnimationPlugin::default()) // <-- Add the plugin .add_startup_system(spawn.system()) .run(); } diff --git a/src/animation.rs b/src/animation.rs index 0e56a0a..649bca3 100644 --- a/src/animation.rs +++ b/src/animation.rs @@ -10,12 +10,13 @@ use bevy_reflect::TypeUuid; #[uuid = "6378e9c2-ecd1-4029-9cd5-801caf68517c"] pub struct SpriteSheetAnimation { /// Frames - pub frames: Vec, + pub(crate) frames: Vec, /// Animation mode pub(crate) mode: AnimationMode, } /// Animation mode (run once, repeat or ping-pong) +#[non_exhaustive] #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum AnimationMode { /// Runs the animation once and then stop playing @@ -33,9 +34,9 @@ pub enum AnimationMode { #[derive(Debug, Copy, Clone, Default)] pub struct Frame { /// Index in the sprite atlas - pub index: usize, + pub(crate) index: usize, /// How long should the frame be displayed - pub duration: Duration, + pub(crate) duration: Duration, } impl SpriteSheetAnimation { @@ -60,14 +61,11 @@ impl SpriteSheetAnimation { /// /// # Example /// + /// You may use this to create a reversed animation: /// ``` /// # use benimator::SpriteSheetAnimation; /// # use std::time::Duration; - /// // Easily create a reversed animation /// let animation = SpriteSheetAnimation::from_iter((0..5).rev(), Duration::from_millis(100)); - /// - /// assert_eq!(animation.frames.iter().map(|frame| frame.index).collect::>(), vec![4, 3, 2, 1, 0]); - /// assert!(animation.frames.iter().all(|frame| frame.duration.as_millis() == 100)); /// ``` /// /// For more granular configuration, see [`from_frames`](SpriteSheetAnimation::from_frames) diff --git a/src/lib.rs b/src/lib.rs index 27ed4b0..2bbd972 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,7 @@ //! fn main() { //! App::new() //! .add_plugins(DefaultPlugins) -//! .add_plugin(AnimationPlugin) // <-- Enable sprite-sheet animations +//! .add_plugin(AnimationPlugin::default()) // <-- Enable sprite-sheet animations //! .add_startup_system(spawn.system()) //! // ... //! .run() @@ -125,10 +125,12 @@ mod state; /// Plugin to enable sprite-sheet animation /// /// See crate level documentation for usage +#[non_exhaustive] #[derive(Default)] pub struct AnimationPlugin; /// Labels of systems that run during the post-update stage +#[non_exhaustive] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, SystemLabel)] pub enum AnimationPostUpdateSystem { /// System that update the sprite atlas textures diff --git a/tests/spec.rs b/tests/spec.rs index 1aa8bb0..086ae34 100644 --- a/tests/spec.rs +++ b/tests/spec.rs @@ -132,7 +132,7 @@ fn app() -> App { app.add_plugin(CorePlugin) .add_plugin(AssetPlugin) - .add_plugin(AnimationPlugin); + .add_plugin(AnimationPlugin::default()); app }