Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 984039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:57:06+00:00 2026-05-16T04:57:06+00:00

so I have this spritesheet (4 sprites in a row and 3 in a

  • 0

so I have this spritesheet (4 sprites in a row and 3 in a coloumn) which I use to animate a character in a game I make. It animates just fine without a problem, like I want it to

the problem start to arise when I want to change the state from “dash” (running to the enemy) to “attack” (well, attack the enemy) it doesn’t seem to play the attack sprite from the start (index 0)

I’ve used self._currentFrame = 3 on the set_state(self) function so that when the function changes it resets the frame to the third frame, which makes (self.currentFrame + 1) % 4 returns 0

but still, sometimes it doesn’t do what I want, and start the animation at about index 2 or 3 (the end of animation). How do I make sure that my animation starts at index 0?

my updating code is as follows, if it helps

    self.frameTime += dt

    if self.fps is not -1:
        while self.frameTime > 1.0 / self.fps:
            self.frameTime -= 1.0 / self.fps
            self.currentFrame = (self.currentFrame + 1) % 4
            self.currentVFrame = (self.currentVFrame + 1) % 3
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:57:06+00:00Added an answer on May 16, 2026 at 4:57 am

    Thanks Andrew, but I’ve solved it. It turned out I just need to adjust the self.fps(the animation fps, not the screen) so that 1.0 / self.fps is smaller than self.frameTime

    Thanks Andrew, is there any way I can give you reputation? or end this question?

    edit:
    why the currentFrame printed as 3?
    The Actor class (the class that inherited from AnimatedGameObject) has a set_state(self, newState) function (which changes the self.currentFrame to 3) that changes the state, so that the update code above (as I’ve explained) returns 0 and the animation starts at the beginning of the frame

    The problem is when the self.fps in the update(self, dt) function has a value of 4, the 1.0 / self.fps has a lesser value than the self.frameTime and as the effect, the self.currentFrame is not set to 0 at the beginning of the animation
    So I actually just need to double the self.fps to 8 and the code works just like I want it to

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a one spritesheet image with all sprites, I downloaded this image from
I have sprites which are spawning from bottom to top. They are coming randomly
I have a base class called SpriteSheet which has two children, RotatedSpriteSheet and FlippedSpriteSheet.
I'm trying to use an xml file for spritesheet data; I have a frame
i have three simple images of a hen which i am trying to animate(hen
I have this webpage which shows me some images and some images are on
I have this little code which lists all matches of items that contains the
I have this code in jQuery, that I want to reimplement with the prototype
I have this idea for a free backup application. The largest problem I need
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.