Phaser.Utils = { 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; } } ; 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]'; } ; }