mirror of
https://github.com/wassname/phaser.git
synced 2026-07-30 12:30:07 +08:00
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:
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user