Phaser current version test environment

Basic Phaser setup for testing

by Lewis Lane

HTML

<script src="https://rawgit.com/photonstorm/phaser/master/build/phaser.min.js"></script>
<div id="test"></div>

JavaScript

// Phaser current version test environment
// Unique click IDs

var game = new Phaser.Game(500, 400, Phaser.CANVAS, 'test');

var BasicGame = function(game) {};

BasicGame.Boot = function (game) {
    // nothing here
};

// the ID of the click
var clickID = 0;
// the variable that stores the timeout value
var clickTimeout = 0;
// how long should we wait after the last click before we increment the ID (in ms)
var clickTimeoutLength = 1000;

BasicGame.Boot.prototype = 
{
    preload: function() {
      game.time.advancedTiming = true;
    },
	create: function() 
	{
        game.input.onDown.add(function() {
            // enough time has passed between clicks, so increment the ID
            if (game.time.now > clickTimeout) {
                clickID++;
            }
            // reset the timeout
            clickTimeout = game.time.now + clickTimeoutLength;   
        }, this);
    },
    update: function() 
    {

    }, 
    render: function()
    {   
        game.debug.text("Click ID: " + clickID, 200, 200);
        
        game.debug.text(game.time.fps || '--', 2, 14, "#00ff00");
        game.debug.text(Phaser.VERSION, game.world.width - 55, 14, "#ffff00");
    }
};

game.state.add('Boot', BasicGame.Boot);
game.state.start('Boot');