Discord
Login
Community
DARK THEME

Get current frame of a sprite

Hi everyone,

I'm struggling to get the current frame on a sprite. I noticed there was no getFrame() function like there is a setFrame(). ojbect.current_frame property always seems to report as 0. Any ideas?

Hi,

I'm afraid you will have to control when to draw each frame:

https://microstudio.dev/community/help/animations-not-looping/119/0/

To get the current frame of a sprite, let's say your sprite name is "mySprite" and your sprite has 5 frames and you have a variable named "myVar" and you want a variable to go up by 1 everytime your sprite gets to its last frame:

if sprites.mySprite.current_frame == 5 then
  myVar += 1
  print(myVar)
end

Hi @Crafterz125,

Have you checked if your solution actually works?

Here is the link to an old discussion on Discord:

https://discord.com/channels/593735633130749972/651013154448605184/790868577884176394

Would be nice if it would work that way, but so far the 'current_frame' doesn't seem to show the current animation frame.

I am adding sprite.getFrame() with the next update

@gilles Thanks.

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community