Phaser current version test environment

Basic Phaser setup for testing

by Lewis Lane

HTML

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

CSS

body {
    background: #333;
}

JavaScript

// Phaser current version test environment
// TweenManager#removeFrom implementation

/**
* Remove all tweens from a specific object, array of objects or group.
*
* @method Phaser.TweenManager#removeFrom
* @param {object|object[]|Phaser.Group} obj - The object you want to remove the tweens from.
* @param {boolean} children - If passing a group, setting this to true will remove the tweens from all of its children instead of the group itself.
*/
Phaser.TweenManager.prototype.removeFrom = function(obj, children) {
        
        var o, c, t, len;
        
        if (Array.isArray(obj) )
        {
            for (o = 0, len = obj.length; o < len; o++)
            {
                this.removeFrom(obj[o]);   
            }
        }
        else if (obj.type === Phaser.GROUP && children)
        {
            for (c = 0, len = obj.children.length; c < len; c++)
            {
                this.removeFrom(obj.children[c]);   
            }
        }
        else
        {
            for (t = 0, len = this._tweens.length; t < len; t++)
            {
                if (obj === this._tweens[t]._object)
                {
                    this.remove(this._tweens[t]);
                }
            }
            for (t = 0, len = this._add.length; t < len; t++)
            {
                if (obj === this._add[t]._object)
                {
                    this.remove(this._add[t]);
                }
            }
        }
};

var game = new Phaser.Game(600, 400, Phaser.AUTO, 'test', null, false, false);

var BasicGame = function (game) {};

BasicGame.Boot = function (game) {};

BasicGame.Boot.prototype = {
    preload: function () {
        
    },
    create: function () {
        var squareBmp = game.add.bitmapData(32, 32);
        squareBmp.rect(0, 0, 32, 32, '#0f0');
        
        var squareGroup = game.add.group(), squares = [], square;
        for (var i = 0; i < 15; i++) {
            square = game.add.sprite((i * 36) + 48, game.world.centerY,...