Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.