Phaser current version test environment

Basic Phaser setup for testing

by Lewis Lane

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.2/phaser.min.js"></script>
<div id="test"></div>

JavaScript

// Phaser current version test environment
// Circular motion

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

var BasicGame = function(game) {};

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

var square;

BasicGame.Boot.prototype = 
{
    preload: function() {
      game.time.advancedTiming = true;
    },
	create: function() 
	{
        square = game.add.graphics();
        square.beginFill(0xffffff);
        square.drawRect(-16, -16, 32, 32);
    },
    update: function() {
        var period = game.time.now * 0.001;
        var radius = 60;
        square.x = game.world.centerX + Math.cos(period) * radius;
        square.y = game.world.centerY + Math.sin(period) * radius;
    },
    render: function()
    {
        game.debug.text(game.time.fps || '--', 2, 14, "#00ff00");   
    }
};

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