How to get current image of flipbook animation?

Hi friends
I have dice flipbook animation with 6 images on it, I play it uing this line of code:

sprite.play_flipbook("/dice#sprite", "dice")

After playing this animation i want to know current image on playing animation ( ie when i press keyboard button ).
how can i get current image of animation group which is playing?
how can i set one of those images of animation as current image? ( for example i want to set it to 3rd image )
Thanks

Perhaps by using cursor and offset ?

1 Like

thanks selimanac , yes I think cursor wokrs, it needs simple calculation to find frame number from float number.
i have tested this line of code to set playback_rate:

go.set("/dice#sprite", "playback_rate", 0)

but this one is not working to set offset

go.set("/dice#sprite", "offset", 2)

‘/dice#sprite’ does not have any property called ‘offset’

edit:
I have used cursor itself to set too:

go.set("/dice#sprite", "cursor", 0.5)

cursor itself is enough :+1:

1 Like

offset is the property of sprite.play_flipbook()
sprite.play_flipbook(url,id,[complete_function],[play_properties])

I’m not on the computer now, I’m not able to test it but something like this:

local  play_properties = {
offset  = 0.5  -- normalized initial value of the animation cursor 
playback_rate = 0
}

sprite.play_flipbook(url,id,[complete_function],play_properties)
1 Like

I’m on the computer and i have tested it, it works well too, thanks a lot :+1:

1 Like