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
// Graphics to textures

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

var BasicGame = function(game) {};

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

BasicGame.Boot.prototype = 
{
    preload: function() {
      game.time.advancedTiming = true;
    },
	create: function() 
	{
        var graphics = game.make.graphics();
        graphics.lineStyle(2, 0x007c00);
        graphics.beginFill(0x00ff00);
        graphics.boundsPadding = 0;
        
        var radius = 64;

        graphics.moveTo(0, radius);
        for (var i = 1; i < 7; i++) {
            var angle = Math.PI / 2 + Math.PI * i / 3;
            graphics.lineTo(radius * Math.cos(angle), radius * Math.sin(angle));
        }
        graphics.cacheAsBitmap = true;
        
        this.hexagonSprite = game.add.sprite(game.world.centerX, game.world.centerY, graphics._cachedSprite.texture);
        this.hexagonSprite.anchor.setTo(0.5);
    },
    update: function() 
    {
        this.hexagonSprite.angle++;
    }, 
    render: function()
    {        
        game.debug.spriteBounds(this.hexagonSprite);
        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');