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
// Discreet rather than continuous movement

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

var BasicGame = function(game) {};

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

var emitter;

BasicGame.Boot.prototype = 
{
    preload: function() {
      game.time.advancedTiming = true;
    },
	create: function() 
	{
        // create our 'player' (a circle)
        this.circle = game.add.graphics();
        this.circle.beginFill(0xffffff);
        this.circle.drawCircle(-10, -10, 20);
        this.circle.x = game.world.centerX;
        this.circle.y = game.world.centerY;
        
        // set up the cursor keys
        this.cursors = game.input.keyboard.createCursorKeys();
        
        // up key
        this.cursors.up.onDown.add(function() {
            this.moveCircle(0, -1);
        }, this);
        
        // down key
        this.cursors.down.onDown.add(function() {
            this.moveCircle(0, 1);
        }, this);
        
        // left key
        this.cursors.left.onDown.add(function() {
            this.moveCircle(-1, 0);
        }, this);
        
        // right key
        this.cursors.right.onDown.add(function() {
            this.moveCircle(1, 0);
        }, this);
    },
    update: function() 
    {
        
    }, 
    render: function()
    {        
        game.debug.text(game.time.fps || '--', 2, 14, "#00ff00");
        game.debug.text(Phaser.VERSION, game.world.width - 55, 14, "#ffff00");
    },
    // Here is where the magic happens. 'delta' in this situation means 'difference' - this is used to multiply the distance variable below, so a deltaX of -1 will add -40 to the object's x coordinate, moving it left by 40 pixels.
    moveCircle: function(deltaX, deltaY) {
        var distance = 40;
        // ensure deltaX and deltaY are 0 if not provided
        deltaX = deltaX || 0;
        deltaY = deltaY || 0;
        // create a tween which moves the circle over half...