Navigation Menu

Skip to content

Commit

Permalink
updates for requestAnimFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
cgack committed Jul 31, 2012
1 parent cbe91a6 commit 4ddc391
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions main.js
Expand Up @@ -86,8 +86,8 @@ var jsApp = {
return; return;
} }
//TODO: fix useNativeAnimFrame to not increase velocities on reload of levels //TODO: fix useNativeAnimFrame to not increase velocities on reload of levels
//me.sys.useNativeAnimFrame = true; me.sys.useNativeAnimFrame = true;
me.sys.fps = 30; me.sys.fps = 60;
//me.debug.renderHitBox = true; //me.debug.renderHitBox = true;
// initialize the "audio" // initialize the "audio"
me.audio.init("ogg"); me.audio.init("ogg");
Expand Down
13 changes: 8 additions & 5 deletions melon.js
Expand Up @@ -1865,17 +1865,19 @@
_animFrameId = window.requestAnimFrame(_renderFrame); _animFrameId = window.requestAnimFrame(_renderFrame);


if (_animFrameId != -1) { if (_animFrameId != -1) {
return; window.setTimeout(_activeUpdateFrame, _fps);
//return;
} }
// else feature not supported ! // else feature not supported !


// disable use of requestAnimationFrame (since unsupported) // disable use of requestAnimationFrame (since unsupported)
me.sys.useNativeAnimFrame = false; me.sys.useNativeAnimFrame = false;
//console.log("using setInterval as fallback ("+_animFrameId+")"); //console.log("using setInterval as fallback ("+_animFrameId+")");
} } else {


// setup the game loop using setInterval // setup the game loop using setInterval
_intervalId = setInterval(_activeUpdateFrame, _fps); _intervalId = setInterval(_activeUpdateFrame, _fps);
}
} }
} }
; ;
Expand All @@ -1885,10 +1887,11 @@
* this is only called when using requestAnimFrame stuff * this is only called when using requestAnimFrame stuff
*/ */
function _renderFrame() { function _renderFrame() {

window.requestAnimFrame(_renderFrame);
_activeUpdateFrame(); _activeUpdateFrame();
// we already checked it was supported earlier // we already checked it was supported earlier
// so no need to do it again here // so no need to do it again here
window.requestAnimFrame(_renderFrame);
} }
; ;


Expand Down

0 comments on commit 4ddc391

Please sign in to comment.