jcornaz / benimator Goto Github PK
View Code? Open in Web Editor NEWA sprite animation library for rust game development
License: The Unlicense
A sprite animation library for rust game development
License: The Unlicense
Given that the play component is meant to trigger or pause animations, it should use SparseSet storage instead of Archetype storage to prevent archetype table copy. This could be a significant overhead if one has a large number of animated entities that need to be paused all at once (say the user presses pause and that needs to pause all animations)
I have an use case where I am extracting animation data from .aseprite
files using bevy_ase
. The process is very smooth and a nice thing is that, using the benimator
feature of that crate, I am able to transform the extracted animation tags (frame ranges) into SpriteSheetAnimation
objects which I can attach to my entities and use normally. That unexpected integration between the projects saved a lot of time on my end in that I don't have to reinvent an animation system from scratch ๐ ๐ โค๏ธ
The problem is, I cannot dynamically alter the playback speed of the extracted animations, which would be useful in my project, as the hero can walk in different terrains and I'd like to speed up/slow down its walk cycle ๐ without resorting to recreating the animation frames from scratch ๐ต
My idea is for us to have an additional optional component that, when applied, will reach benimator
's internal "update animation" system, altering the behavior of the update() function to take into consideration said multiplier ๐ค ๐
We more often think of animaton speed in terms of "frame-per-second" that "frame-duration".
Therefore, the user should be able to define the animation FPS. (frame-duration = 1 / FPS
)
Let's say I want to animate pacman. In that case, the animation mode I want is PingPong
.
For example I could define the frame range to 0..=3
and the animation would loop like this: 0 1 2 3 2 1 0 1 2 3 ...
forever.
I found this incredible crate and use it for some cool game dev, it was really fun!
However, I also worked with the newly released bevy_tweening
crate and needed a way to detect the end of animations to do some stuff. I proposed that we could use the same technique as you are using: removing a Play
component. Unfortunately, we asked some ECS peeps about doing that compared to using Events
instead, their answer was that we should prefer using Events
for performances reasons.
I know that the Play
component plays more than this role of detecting the end of an animation, but maybe you would be interested in this. As I understand it is preferable to avoid adding/removing components too much from the ECS and prefer doing things like in bevy_tweening
by using the Animator
and changing its state.
How can I have animation to run once on demand? I need to show shot splash animation each time player does a shot. I see 2 options here:
visibility: Visibility{is_visible: false},
. And then on each shoot to add Play
component in it and set up visibility to true. The problem here is how do I differ shot animation entity from other animation entities?Hi, I'm struggling with figuring out how I could switch between 2 different animation sets. I have a texture atlas for idle animations and 1 for running animations. How do I switch between those two?
Would be great to queue up a new animation, or specify a default animation to run once one finishes
As suggested in bevy discord: https://discord.com/channels/691052431525675048/691052431974465548/928336941643075606
Right now I am leaning toward a flag in the animation state component. So that it is possible to change the direction without changing the animation resource.
In the case where the Play
component is remove to pause the animation, I would like to reset the sprite index to 0 (an idle "looking" state). Manually update the Frame
?
Also, thanks for the great library!
I'm currently trying to trigger some logic at a specific frame of the animation, but it seems SpriteSheetAnimationState::current_frame
isn't public, is there are reason for that?
Also I think a more powerful system which automatically sends events for tagged frames (which you would tag when constructing the animation), would be very helpful for many cases.
The cargo feature unstable-load-from-file
allows loading animation from YAML or RON files.
Eventually, this should be stabilized. The present issue is there to track what needs to be considered/done before stabilizing the feature.
It is also open to gathering comments and thoughts about the current state of the API.
load-from-file
gate)from_(yaml|ron)_(str|bytes)
.
serde::Deserialize
is enough to let the user choose the format and library of their choice. Not to mention that most users would not use it directly anyway as they would use the asset loader instead..animation.(yaml|yml|ron)
a good choice?
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
This repository currently has no open or pending branches.
Cargo.toml
serde 1.0
serde_yaml 0.9.34
rstest 0.19.0
anyhow 1.0
toml 0.8.12
rustc_version 0.4.0
.github/workflows/check.yml
actions/checkout v4
Swatinem/rust-cache v2
taiki-e/install-action v2
actions/checkout v4
Swatinem/rust-cache v2
taiki-e/install-action v2
.github/workflows/create-release.yml
actions/checkout v4
taiki-e/create-gh-release-action v1
Currently, the Animation structures are constructed at runtime, which works well for dynamic and interactive applications.
I propose adding the capability to build Animation structures at compile time. This feature would allow developers to define animations that are static and unchanging throughout the application's life, ensuring these animations are constructed and optimized during compilation, reducing runtime overhead and potentially improving the application's overall performance. (The main reason is for design purposes)
I believe this feature could be implemented by providing a macro or a set of const functions that allow for the construction of Animation structures with fixed parameters. This way, developers can opt-in to compile time construction where it makes sense for their application.
Sometimes, especially for visual effects or one-shot animations, it is helpful to define the whole animation duration rather than its speed.
Any chance to get support for loading a SpriteSheetAnimation from a file (behind a feature flag)? For example, one could load them from .ron.animation
files.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.