Skip to content

Instantly share code, notes, and snippets.

@georgiee
Created April 28, 2014 11:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgiee/11368709 to your computer and use it in GitHub Desktop.
Save georgiee/11368709 to your computer and use it in GitHub Desktop.
Polyfill Uint32Array (for Phaser 2.0.3+)
//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