mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Fixed and tested on IE9.
This commit is contained in:
parent
75a848f0ef
commit
9fd4ac5950
2 changed files with 82 additions and 70 deletions
|
@ -65,18 +65,6 @@ Phaser.BitmapData = function (game, key, width, height) {
|
|||
*/
|
||||
this.imageData = this.context.getImageData(0, 0, width, height);
|
||||
|
||||
/**
|
||||
* @property {ArrayBuffer} buffer - An ArrayBuffer the same size as the context ImageData.
|
||||
*/
|
||||
if (this.imageData.data.buffer)
|
||||
{
|
||||
this.buffer = this.imageData.data.buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.buffer = new ArrayBuffer(this.imageData.data.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* @property {Uint8ClampedArray} data - A Uint8ClampedArray view into BitmapData.buffer.
|
||||
*/
|
||||
|
@ -85,7 +73,28 @@ Phaser.BitmapData = function (game, key, width, height) {
|
|||
/**
|
||||
* @property {Uint32Array} pixels - An Uint32Array view into BitmapData.buffer.
|
||||
*/
|
||||
this.pixels = new Uint32Array(this.buffer);
|
||||
this.pixels = null;
|
||||
|
||||
/**
|
||||
* @property {ArrayBuffer} buffer - An ArrayBuffer the same size as the context ImageData.
|
||||
*/
|
||||
if (this.imageData.data.buffer)
|
||||
{
|
||||
this.buffer = this.imageData.data.buffer;
|
||||
this.pixels = new Uint32Array(this.buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (window['ArrayBuffer'])
|
||||
{
|
||||
this.buffer = new ArrayBuffer(this.imageData.data.length);
|
||||
this.pixels = new Uint32Array(this.buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pixels = this.imageData.data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @property {PIXI.BaseTexture} baseTexture - The PIXI.BaseTexture.
|
||||
|
@ -265,19 +274,26 @@ Phaser.BitmapData.prototype = {
|
|||
if (typeof height === 'undefined') { height = this.height; }
|
||||
|
||||
this.imageData = this.context.getImageData(x, y, width, height);
|
||||
this.data = this.imageData.data;
|
||||
|
||||
if (this.imageData.data.buffer)
|
||||
{
|
||||
this.buffer = this.imageData.data.buffer;
|
||||
this.pixels = new Uint32Array(this.buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.buffer = new ArrayBuffer(this.imageData.data.length);
|
||||
if (window['ArrayBuffer'])
|
||||
{
|
||||
this.buffer = new ArrayBuffer(this.imageData.data.length);
|
||||
this.pixels = new Uint32Array(this.buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pixels = this.imageData.data;
|
||||
}
|
||||
}
|
||||
|
||||
this.data = this.imageData.data;
|
||||
this.pixels = new Uint32Array(this.buffer);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -320,60 +320,56 @@ if (!Array.prototype.forEach)
|
|||
};
|
||||
}
|
||||
|
||||
(function(global, undefined) {
|
||||
|
||||
/**
|
||||
* Low-budget Float32Array knock-off, suitable for use with P2.js in IE9
|
||||
* Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/
|
||||
* Cameron Foale (http://www.kibibu.com)
|
||||
*/
|
||||
if (typeof global.Uint32Array !== "function")
|
||||
/**
|
||||
* Low-budget Float32Array knock-off, suitable for use with P2.js in IE9
|
||||
* Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/
|
||||
* Cameron Foale (http://www.kibibu.com)
|
||||
*/
|
||||
if (typeof window.Uint32Array !== "function")
|
||||
{
|
||||
var CheapArray = function(type)
|
||||
{
|
||||
var CheapArray = function(type)
|
||||
{
|
||||
var proto = new Array(); // jshint ignore:line
|
||||
|
||||
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);
|
||||
var proto = new Array(); // jshint ignore:line
|
||||
|
||||
this.length = arg.length;
|
||||
|
||||
for (var i = 0; i < this.length; i++)
|
||||
{
|
||||
this[i] = arg[i];
|
||||
}
|
||||
window[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;
|
||||
}
|
||||
};
|
||||
|
||||
global[type].prototype = proto;
|
||||
global[type].constructor = global[type];
|
||||
}
|
||||
else
|
||||
{
|
||||
Array.call(this, arg.length);
|
||||
|
||||
this.length = arg.length;
|
||||
|
||||
for (var i = 0; i < this.length; i++)
|
||||
{
|
||||
this[i] = arg[i];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CheapArray('Uint32Array'); // jshint ignore:line
|
||||
CheapArray('Int16Array'); // jshint ignore:line
|
||||
}
|
||||
|
||||
/**
|
||||
* Also fix for the absent console in IE9
|
||||
*/
|
||||
if (!window.console)
|
||||
{
|
||||
window.console = {};
|
||||
window.console.log = window.console.assert = function(){};
|
||||
window.console.warn = window.console.assert = function(){};
|
||||
}
|
||||
|
||||
})(this);
|
||||
|
||||
window[type].prototype = proto;
|
||||
window[type].constructor = window[type];
|
||||
};
|
||||
|
||||
CheapArray('Uint32Array'); // jshint ignore:line
|
||||
CheapArray('Int16Array'); // jshint ignore:line
|
||||
}
|
||||
|
||||
/**
|
||||
* Also fix for the absent console in IE9
|
||||
*/
|
||||
if (!window.console)
|
||||
{
|
||||
window.console = {};
|
||||
window.console.log = window.console.assert = function(){};
|
||||
window.console.warn = window.console.assert = function(){};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue