HTML5 Crossbrowser Development - JavaScript interpreter speed
Hello,
I have developed a browser game with javascript and html5 which i would like to publish as mobile web app. My main game is drawed in a canvas object.
Sadly it only works correctly with Google Chrome 25 now! The reason is that in other browsers (tested with Firefox 19 and Opera 12.14) the animations are much too slow.
The main game loop which invokes the methods for moving objects and drawing objects on screen is called endless repeating by a setTimeout-command with a 20ms delay.
I dont understand why there are so big time differences between chrome and other browsers, because the operations are not as expensive (or I do not know the reason).
Here is a sample of my code:
[...]
oGame.play = function() {
oGame.moveObjects();
oScreen.draw();
[...]
setTimeout("oGame.play()", 20);
}
[...]
Does somebody know further? Much thanks in advance!
Kind regards,
Philip
"Ein Kritiker ist ein Mann ohne Beine, der das Laufen lehrt!" - Channing Pollock
(A critic is a man without stand who teaches going!)