The Timer will no longer create negative ticks during game boot, no matter how small the Timer delay is (fixes #366)

This commit is contained in:
photonstorm
2014-02-26 19:52:23 +00:00
parent 493c12c807
commit db090601b8
6 changed files with 68 additions and 42 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render }, true);
function preload() {
@@ -15,7 +15,7 @@ var music;
function create() {
game.stage.backgroundColor = '#182d3b';
// game.stage.backgroundColor = '#182d3b';
game.input.touch.preventDefault = false;
music = game.add.audio('boden');
+17 -18
View File
@@ -1,30 +1,29 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create });
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('pic', 'assets/pics/backscroll.png');
}
var text;
var b;
var grd;
var last;
var i = 0;
function create() {
game.stage.setBackgroundColor(0x2d2d2d);
//Maybe you have to set it even lower for your machine.
//It's related to the time Phaser needs to boot up.
//The tick stops being negative and behaves nearly normal for me at around 550 - 600ms
text = game.add.text(0, 0, "time");
delay = 250;
foreverTimer = game.time.events.repeat(delay, 10, handleEvent, this);
last = Date.now();
console.log('create started', last);
}
function update() {
function handleEvent() {
console.log('>> Tick', i, 'ms diff:', Date.now() - last);
}
last = Date.now();
function render() {
i++;
}
}