EngoEngine / engo

Engo is an open-source 2D game engine written in Go.
https://engoengine.github.io
MIT License
1.74k stars 136 forks source link

Export current frame in the Animation Component #752

Closed Noofbiz closed 3 years ago

Noofbiz commented 3 years ago

So you can add triggers based on the current frame rather than have to time it out and hope they sync up :P

This would be so, say, you wanted an attack's hitbox to activate four frames into the animation rather than at the first frame. As it is now, you can do it by having another system just keep time and change the hitbox after a set amount of time, but if frame rate is off or something you could end up with the hitbox being active earlier or later than expected. By exposing the current frame, we can wait until the frame is the right one before activating, which would be much more precise and ecs-friendly.

ETA: maybe not export it, but add a method like func (a *AnimationComponent)CurrentFrame() int that returns the current frame.