Expand description

A sprite animation library for rust game development

Initially designed for bevy, it is now engine agnostic.

Get started

benimator assumes usage of texture atlas (or equivalent).

An Animation contains the list of animation frames, each frame defined by an index.

use std::time::Duration;
use benimator::{Animation, State};

// Create an animation
let frame_duration = Duration::from_millis(100);
let animation = Animation::from_range(0..=3, frame_duration);

// Get a new animation state
let mut state = State::default();

// At each game-loop update, tell the state how much time has elapsed
let delta_time = Duration::from_millis(250);
state.update(&animation, delta_time);

// Then we can get the current frame index in order to render the right sprite
assert_eq!(state.sprite_frame_index(), 2);

Structs

Definition of an animation

A single animation frame

Animation state