View Single Post
Old 01-10-2013, 02:39 PM   PM User | #1
nikos101
Senior Coder

 
nikos101's Avatar
 
Join Date: Dec 2006
Location: London
Posts: 1,004
Thanks: 58
Thanked 10 Times in 10 Posts
nikos101 is an unknown quantity at this point
The setInterval timing is not consistent across browsers.

Hi, I'm finding that the he elapsed number which is determined by the setInterval function is not consistent across browsers. The value can vary considerably. Can anyone advise on a way to get it more uniform.

update(elapsed: number) { var elapsedUnit = elapsed / 10;

this code is called based on this setInterval code :

$(document).ready(function () {
var game: Game = new Game;

$(document).keydown(game.onKeyDown);
$(document).keyup(game.onKeyUp);
//game.update();
//game.draw();
var timeA = new Date().getTime();
setInterval(function () {

var timeB = new Date().getTime();
var elapsedTime = timeB - timeA

game.update(elapsedTime);
game.draw();
}, 1000 / this.FPS);

});
__________________

nikos101 is offline   Reply With Quote