-
Notifications
You must be signed in to change notification settings - Fork 15
How to execute logic when the animation reaches a specific frame? #46
Comments
Yes, and it should stay private so that we can change internal representation without breaking the API. But eventually, we may expose a getter.
Interesting, that sounds like a good idea. Let's explore how the API could look like. I will think about it on my side, feel free to share your ideas about how you would like to use it ;-) |
I agree, this makes a lot of sense for a crate >1.0. Sadly it's really hard to use the crate, when missing features can only be achieved by hacks or forking it. Generally exposing these kind of fields seems like a good idea to me.
I probably would just add something like SpriteSheetAnimation::<Event>::with(frame_tag_map: BTreeMap<usize, Event>) which sends the according event when "starting" a frame. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as outdated.
This comment was marked as outdated.
Maybe worth noting: The sprite sheet frame is publicly accessible. So it is already possible to observe changes of the sprite-sheet itself instead of observing changes of the animation state. |
It looks like bevy assets cannot be generic. So that wouldn't work, sadly :-/ |
Sorry by exposing I meant in any way, not necessarily by making it public, which we agree is not a good option here. And I think being able to set the frame might also be important for some things? |
sure the
Oh I didn't know that. That's a bummer. I guess we would need to work with |
I am not yet sure how to approach the implementation of dispatching the event if the assets contain a A simple solution for now may be to add a |
We should be able to implement TypeUuid ourselves. Also an PR is
I would do that regardless, but maybe directly also allow setting it? |
The trait definition is: pub trait TypeUuid {
const TYPE_UUID: Uuid;
} So we have to return a constant uuid associated for the type. It's not very easy to implement, we probably have to do it via macro. If you feel confident about a possible implementation, you may share code (either in this issue, as a conceptual implementation, or in the form of a pull request)
What would be the use-case for setting it? My approach is usually to wait for the need before adding a new public member (aka YAGNI). This is somehow an echo of what I was saying about breaking changes. The more public members, the higher chances are that I find myself in the difficult situation of having the break the API, therefore I make sure they actually bring value. For the getter, I am okay because the need arose (and is documented in the present issue), for the setter I would like to hear what's the use-case first. |
For now, we can go with the |
Great! Yes I would just wait for mentioned bevyengine/bevy/pull/4118 to hit stable and then we should be able to implement the discussed API easily.
I understand that idiom, I guess I'm just coming from a different perspective. I took part in the Bevy Jam 1 last week and just wanted to be able to do stuff rather than having to start (and keep) my own fork around which exposes the frame number. So that was just thinking into the future where a need for setting the frame number could arise. But for any other project this should be a totally fine and probably better idiom. |
bevyengine/bevy#4118 was merged and should be included in the now released |
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 text was updated successfully, but these errors were encountered: