How can I get the current flipbook frame?

Is there a way to get the frame that a paper flipbook component is currently on?

I see there is a way to get the sprite at a certain frame or time, and a way to get the number of frames. But I’m specifically trying to get the current frame.

This stores the current frame since game start, could be modified further possibly to fit your needs.

37511-current+frame.png

I was hoping I would have to do this kind of thing, but if there’s nothing built into the flipbook class, I suppose it’ll do. Thanks.

In case some frames are skipped, this counter will be “shifted”. It will be always wrong from there on.

FlipbookComponent has a cachedFrameIndex variable, sadly it’s protected. So you can’t get it that easily.

What I needed was to trigger events on specific frames. This can be achieved with Timers. I haven’t implemented it yet though.

This might help. I created a function that calculates if you are between two frames. It’s not immune to slips, but should be pretty resistant, I think.

1)So outside of the function you need a float called “Delta counter” or something similar, and have it increment by delta every tick.

2)Similarly you need to set the counter to 0 whenever you are starting an animation.

  1. Sprite Animation is the name of the flipbook.

Then whenever you need to check if you are a certain spot you can just call this function and pass in the first and last of the important key frames and it will return a boolean.