Fixed issue where Phaser.Canvas.create would always make a screencanvas for CocoonJS, but that should only happen once. New parameter toggles it.

This commit is contained in:
photonstorm
2014-02-28 03:55:06 +00:00
parent 34ee2b0b20
commit 09d4a35b7f
14 changed files with 688 additions and 273 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ Phaser.BitmapData = function (game, key, width, height) {
* @property {HTMLCanvasElement} canvas - The canvas to which this BitmapData draws.
* @default
*/
this.canvas = Phaser.Canvas.create(width, height);
this.canvas = Phaser.Canvas.create(width, height, '', true);
/**
* @property {CanvasRenderingContext2D} context - The 2d context of the canvas.
+13 -3
View File
@@ -19,16 +19,26 @@ Phaser.Canvas = {
* @param {number} [width=256] - The width of the canvas element.
* @param {number} [height=256] - The height of the canvas element..
* @param {string} [id=''] - If given this will be set as the ID of the canvas element, otherwise no ID will be set.
* @param {boolean} [noCocoon=false] - CocoonJS only allows 1 screencanvas object, which should be your game. If you need to create another canvas (i.e. for a texture) set this to 'true'.
* @return {HTMLCanvasElement} The newly created canvas element.
*/
create: function (width, height, id) {
create: function (width, height, id, noCocoon) {
if (typeof noCocoon === 'undefined') { noCocoon = false; }
width = width || 256;
height = height || 256;
var canvas = document.createElement(navigator.isCocoonJS ? 'screencanvas' : 'canvas');
if (noCocoon)
{
var canvas = document.createElement('canvas');
}
else
{
var canvas = document.createElement(navigator.isCocoonJS ? 'screencanvas' : 'canvas');
}
if (typeof id === 'string')
if (typeof id === 'string' && id !== '')
{
canvas.id = id;
}
+1 -1
View File
@@ -40,7 +40,7 @@ Phaser.TilemapLayer = function (game, tilemap, index, width, height) {
/**
* @property {HTMLCanvasElement} canvas - The canvas to which this TilemapLayer draws.
*/
this.canvas = Phaser.Canvas.create(width, height);
this.canvas = Phaser.Canvas.create(width, height, '', true);
/**
* @property {CanvasRenderingContext2D} context - The 2d context of the canvas.