Jump to content

Opera Android FPS is above 100


kuuuurija
 Share

Recommended Posts

You could simply calculate the fps and update your game at a fix rate.

 

Are you using requestAnimationFrame in Chrome, Opera and Firefox ? What is your Android version ?

 

solved.

ya, I am using requestAnimationFrame. (Android 4.1.x) I fixed it by adding requestAnimationFrame to setTimeout.

var fps = 60;function draw() {    setTimeout(function() {        requestAnimationFrame(draw);        // redraw code    }, 1000 / fps);}
Link to comment
Share on other sites

I think you are doing a mistake if you mix setTimeout with requestAnimationFrame, what I suggested was to effectively calculate the fps and do the game logic update at a fixed fps.

 

setTimeout and setInterval are not meant to be used for a draw cycle.

 

Anyway if you are satisfied with how it works now ...

Link to comment
Share on other sites

I'm new to html5, but usually all realtime games should have what's called a fixed timestep. Which is basically what iprasila was talking about. All you need to do for a simple implementation is change all your fps based values to time based values(e.g instead of setting velocity to 2 pixels per frame, set it to 2 pixels per 50ms). Then in all your update code find the amount of time that elapsed since the last frame and when you update your objects use the elapsed time as a multiplier for your values(using the velocity example: position.x = position.x + velocityPer50ms.x * (timeElapsedInMs / 50))

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...