I know I must be just glancing over this, but I have looked a few times.
I know how to set and get the flipbook sprite, but I have no idea how to return its current image index. Game Maker (as a poor example) has an image_index. I see things like GetSpriteAtFrame, but that is not working. I need to know the current frame of animation the sprite is on at the time of checking.
Thanks for any help.
Sprite->?
Is the answer here somewhere?
Edit: I also need to be able to set the frame, or the image_index.
It would also help to know if the framerate can be set programatically or if setting it on the individual flipbook is the only way. I see a way to GetFlipbookFramerate, but no set.
Edit 2: So we solved the issue on how to get and set the image_index. I am sharing and asking that this be included with Paper2D, as setting the scrubber is not ideal for fighting games.
int32 ATestPlatformOriginalCharacter::get_image_index() {
return Sprite->GetFlipbook()->GetKeyFrameIndexAtTime(Sprite->GetPlaybackPosition());
}
void ATestPlatformOriginalCharacter::set_image_index(int32 frame) {
//Get number of frames.
float framecount = Sprite->GetFlipbookLengthInFrames();
float gettimeposition = (frame + 1) / framecount;
if (gettimeposition > 1) {
Sprite->SetPlaybackPosition(1.0f, false);
} else {
Sprite->SetPlaybackPosition(gettimeposition, false);
}
}