Phaser.Utils = { getProperty: function (obj, prop){ var parts = prop.split('.'), last = parts.pop(), l = _AN_Read_length('length', parts), i = 1, current = parts[0]; while (i < l && (obj = obj[current])){ current = parts[i]; i++ ; } if (obj) { return obj[last]; } else { return null ; } } , setProperty: function (obj, prop, value){ var parts = prop.split('.'), last = parts.pop(), l = _AN_Read_length('length', parts), i = 1, current = parts[0]; while (i < l && (obj = obj[current])){ current = parts[i]; i++ ; } if (obj) { obj[last] = value; } } , transposeArray: function (array){ var result = new Array((_AN_Read_length('length', array[0]))); for (var i = 0; i < _AN_Read_length('length', array[0]); i++ ){ result[i] = new Array((_AN_Read_length('length', array)) - 1); for (var j = _AN_Read_length('length', array) - 1; j > -1; j-- ){ result[i][j] = array[j][i]; } } return result; } , rotateArray: function (matrix, direction){ if (typeof direction !== 'string') { direction = ((direction % 360) + 360) % 360; } if (direction === 90 || direction === -270 || direction === 'rotateLeft') { matrix = Phaser.Utils.transposeArray(matrix); matrix = matrix.reverse(); } else if (direction === -90 || direction === 270 || direction === 'rotateRight') { matrix = matrix.reverse(); matrix = Phaser.Utils.transposeArray(matrix); } else if (Math.abs(direction) === 180 || direction === 'rotate180') { for (var i = 0; i < _AN_Read_length('length', matrix); i++ ){ matrix[i].reverse(); } matrix = matrix.reverse(); } return matrix; } , parseDimension: function (size, dimension){ var f = 0; var px = 0; if (typeof size === 'string') { if (size.substr(-1) === '%') { f = parseInt(size, 10) / 100; if (dimension === 0) { px = window.innerWidth * f; } else { px = window.innerHeight * f; } } else { px = parseInt(size, 10); } } else { px = size; } return px; } , shuffle: function (array){ for (var i = _AN_Read_length('length', array) - 1; i > 0; i-- ){ var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; array[j] = temp; } return array; } , pad: function (str, len, pad, dir){ if (typeof (len) == "undefined") { var len = 0; } if (typeof (pad) == "undefined") { var pad = ' '; } if (typeof (dir) == "undefined") { var dir = 3; } var padlen = 0; if (len + 1 >= _AN_Read_length("length", str)) { switch (dir){ case 1: str = new Array(len + 1 - (_AN_Read_length("length", str))).join(pad) + str; break ; case 3: var right = Math.ceil((padlen = len - _AN_Read_length("length", str)) / 2); var left = padlen - right; str = new Array(left + 1).join(pad) + str + new Array(right + 1).join(pad); break ; default : { str = str + new Array(len + 1 - (_AN_Read_length("length", str))).join(pad); break ; } } } return str; } , isPlainObject: function (obj){ if (typeof (obj) !== "object" || obj.nodeType || obj === obj.window) { return false ; } try { if (obj.constructor && !({ } ).hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf")) { return false ; } } catch (e) { return false ; } return true ; } , extend: function (){ var options, name, src, copy, copyIsArray, clone, target = arguments[0] || { } , i = 1, length = _AN_Read_length("length", arguments), deep = false ; if (typeof target === "boolean") { deep = target; target = arguments[1] || { } ; i = 2; } if (length === i) { target = this; --i; } for (; i < length; i++ ){ if ((options = arguments[i]) != null ) { for (name in options){ src = target[name]; copy = options[name]; if (target === copy) { continue ; } if (deep && copy && (Phaser.Utils.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) { if (copyIsArray) { copyIsArray = false ; clone = src && Array.isArray(src)? src: [] ; } else { clone = src && Phaser.Utils.isPlainObject(src)? src: { } ; } target[name] = Phaser.Utils.extend(deep, clone, copy); } else if (copy !== undefined) { target[name] = copy; } } } } return target; } , mixin: function (from, to){ if (!from || typeof (from) !== "object") { return to; } for (var key in from){ var o = from[key]; if (o.childNodes || o.cloneNode) { continue ; } var type = typeof (from[key]); if (!from[key] || type !== "object") { to[key] = from[key]; } else { if (typeof (to[key]) === type) { to[key] = Phaser.Utils.mixin(from[key], to[key]); } else { to[key] = Phaser.Utils.mixin(from[key], new o.constructor()); } } } return to; } } ; if (typeof Function.prototype.bind != 'function') { Function.prototype.bind = (function (){ var slice = Array.prototype.slice; return function (thisArg){ var target = this, boundArgs = slice.call(arguments, 1); if (typeof target != 'function') { throw new TypeError() } function bound(){ var args = boundArgs.concat(slice.call(arguments)); target.apply(this instanceof bound? this: thisArg, args); } bound.prototype = (function F(proto){ if (proto) { F.prototype = proto; } if (!(this instanceof F)) { return new F(); } } )(target.prototype); return bound; } ; } )(); } if (!Array.isArray) { Array.isArray = function (arg){ return Object.prototype.toString.call(arg) == '[object Array]'; } ; } if (!Array.prototype.forEach) { Array.prototype.forEach = function (fun){ "use strict"; if (this === void 0 || this === null ) { throw new TypeError() } var t = Object(this); var len = _AN_Read_length("length", t) >>> 0; if (typeof fun !== "function") { throw new TypeError() } var thisArg = _AN_Read_length("length", arguments) >= 2? arguments[1]: void 0; for (var i = 0; i < len; i++ ){ if (i in t) { fun.call(thisArg, t[i], i, t); } } } ; } if (typeof window.Uint32Array !== "function") { var CheapArray = function (type){ var proto = new Array(); window[type] = function (arg){ if (typeof (arg) === "number") { Array.call(this, arg); this.length = arg; for (var i = 0; i < _AN_Read_length("length", this); i++ ){ this[i] = 0; } } else { Array.call(this, _AN_Read_length("length", arg)); this.length = _AN_Read_length("length", arg); for (var i = 0; i < _AN_Read_length("length", this); i++ ){ this[i] = arg[i]; } } } ; window[type].prototype = proto; window[type].constructor = window[type]; } ; CheapArray('Uint32Array'); CheapArray('Int16Array'); } if (!window.console) { window.console = { } ; window.console.log = window.console.assert = function (){ } ; window.console.warn = window.console.assert = function (){ } ; }