Jump to content

How does splitting the game FPS and Sprite FPS work?


Jambutters
 Share

Recommended Posts

Noob to game dev here, this is more of a general javascript question but:

I'm looking over kittykatattacks spriteUtilities library and

var frameRate = 1000 / sprite.fps;

        //Set the sprite to the starting frame
        sprite.gotoAndStop(startFrame);

        //Set the `frameCounter` to the first frame
        frameCounter = 1;

        //If the state isn't already `playing`, start it
        if (!sprite.animating) {
timerInterval = setInterval(advanceFrame.bind(this), frameRate);
}

 

So how does this(the sprites fps) not conflict with the games fps? Generally you have the main game update loop somewhere that's also a setInterval(gameLoop, fps).
and javascript is synchronous right?

Link to comment
Share on other sites

You can change the sprite's texture and other properties as often as you like, but render is still called at the same rate* (render handles all of the actual drawing to screen). On the other hand, if you were updating the same property at two different time intervals that could be problematic.

*well, assuming your interval functions finish quickly enough, etc. That's a different issue thou..

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...