mirror of
https://github.com/wassname/phaser.git
synced 2026-08-12 12:20:38 +08:00
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:
@@ -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
@@ -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++;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user