Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updates for requestAnimFrame

  • Loading branch information...
commit 4ddc391941c42bdbff6ef1a5b06edac46ad5a527 1 parent cbe91a6
@cgack authored
Showing with 10 additions and 7 deletions.
  1. +2 −2 main.js
  2. +8 −5 melon.js
View
4 main.js
@@ -86,8 +86,8 @@ var jsApp = {
return;
}
//TODO: fix useNativeAnimFrame to not increase velocities on reload of levels
- //me.sys.useNativeAnimFrame = true;
- me.sys.fps = 30;
+ me.sys.useNativeAnimFrame = true;
+ me.sys.fps = 60;
//me.debug.renderHitBox = true;
// initialize the "audio"
me.audio.init("ogg");
View
13 melon.js
@@ -1865,17 +1865,19 @@
_animFrameId = window.requestAnimFrame(_renderFrame);
if (_animFrameId != -1) {
- return;
+ window.setTimeout(_activeUpdateFrame, _fps);
+ //return;
}
// else feature not supported !
// disable use of requestAnimationFrame (since unsupported)
me.sys.useNativeAnimFrame = false;
//console.log("using setInterval as fallback ("+_animFrameId+")");
- }
+ } else {
- // setup the game loop using setInterval
- _intervalId = setInterval(_activeUpdateFrame, _fps);
+ // setup the game loop using setInterval
+ _intervalId = setInterval(_activeUpdateFrame, _fps);
+ }
}
}
;
@@ -1885,10 +1887,11 @@
* this is only called when using requestAnimFrame stuff
*/
function _renderFrame() {
+
+ window.requestAnimFrame(_renderFrame);
_activeUpdateFrame();
// we already checked it was supported earlier
// so no need to do it again here
- window.requestAnimFrame(_renderFrame);
}
;
Please sign in to comment.
Something went wrong with that request. Please try again.