Skip to content

Commit

Permalink
docs(unstable): document how to load animation from file
Browse files Browse the repository at this point in the history
  • Loading branch information
jcornaz committed Jun 5, 2022
1 parent 4d0ae1c commit e6dff14
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,39 @@
//! }
//! }
//! ```
//!
//! ## **(Unstable)** Load animation from file
//!
//! By enabling the cargo feature: `unstable-load-from-file` you can write the animation in an asset file with the extension `.animation.yml`
//! then load with the asset-server.
//!
//! Here is how the animation file looks like:
//! ```yaml
//! # The mode can be one of: 'once', 'repeat', 'ping-pong'
//! # or 'repeatFrom(n)' (where 'n' is the frame-index to repeat from)
//! # The default is 'repeat'
//! mode: ping-pong
//! frames:
//! - index: 0 # index in the sprite sheet for that frame
//! duration: 100 # duration of the frame in milliseconds
//! - index: 1
//! duration: 100
//! - index: 2
//! duration: 120
//! ```
//!
//! And how to load it with the asset server
//! ```
//! # use bevy::prelude::*;
//! # use benimator::*;
//! fn load(mut commands: Commands, asset_server: Res<AssetServer>) {
//!
//! // Load animation from the asset server
//! let animation_handle: Handle<SpriteSheetAnimation> = asset_server.load("player_run.animation.yml");
//!
//! // TODO insert the handle in an entity...
//! }
//! ```
#[cfg(test)]
#[macro_use]
Expand Down

0 comments on commit e6dff14

Please sign in to comment.