Created
April 28, 2014 11:15
-
-
Save georgiee/11368709 to your computer and use it in GitHub Desktop.
Polyfill Uint32Array (for Phaser 2.0.3+)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Modified | |
| //Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/ | |
| //Cameron Foale (http://www.kibibu.com) | |
| (function(global, undefined) { | |
| /** | |
| * Low-budget Float32Array knock-off, suitable for use with P2.js | |
| */ | |
| if(typeof global.Uint32Array !== "function") | |
| { | |
| var CheapArray = function(type) | |
| { | |
| var proto = new Array(); | |
| global[type] = function(arg) { | |
| if(typeof(arg) === "number") | |
| { | |
| Array.call(this, arg); | |
| this.length = arg; | |
| for (var i = 0; i < this.length; i++) { | |
| this[i] = 0; | |
| }; | |
| } else { | |
| Array.call(this, arg.length); | |
| this.length = arg.length; | |
| for (var i = 0; i < this.length; i++) { | |
| this[i] = arg[i]; | |
| }; | |
| } | |
| } | |
| global[type].prototype = proto; | |
| global[type].constructor = global[type]; | |
| } | |
| CheapArray('Uint32Array'); | |
| CheapArray('Int16Array'); | |
| } | |
| /** | |
| * Also fix for the absent console in IE9 | |
| */ | |
| if(!window.console) { | |
| window.console={}; | |
| window.console.log = window.console.assert = function(){}; | |
| } | |
| })(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment