Phaser FPS Example
In the console, I would expect the time elapsed to be different for each fps value
HTML
<!DOCTYPE html>
<html>
<head>
<script src="//cdn.jsdelivr.net/npm/phaser@3.24.1/dist/phaser.min.js"></script>
<meta charset="UTF-8" />
</head>
<body>
<div id="phaser-example">
</div>
</body>
</html>
JavaScript
var Fps = new Phaser.Class({
Extends: Phaser.Scene,
initialize:
function fps ()
{
Phaser.Scene.call(this, { key: 'Fps' });
this.tick;
},
preload: function ()
{
this.load.atlas('assets', 'assets/games/breakout/breakout.png', 'assets/games/breakout/breakout.json');
},
create: function ()
{
this.physics.world.setFPS(120);
console.log("FPS", this.physics.world.fps)
this.startTime = performance.now()
this.tick = 0;
},
update: function ()
{
if (++this.tick === 500) {
console.log(performance.now() - this.startTime)
}
}
});
var config = {
type: Phaser.WEBGL,
width: 800,
height: 600,
parent: 'phaser-example',
scene: [ Fps ],
physics: {
default: 'arcade'
}
};
var game = new Phaser.Game(config);