From 6fd2b6a7ec616529d3426363f7e25ef2b7fe00fb Mon Sep 17 00:00:00 2001 From: photonstorm Date: Wed, 30 Sep 2015 11:18:53 +0100 Subject: [PATCH] Phaser.Create no longer automatically creates a BitmapData object when it starts. It now only does it when you first make a texture or grid. --- src/core/Create.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/core/Create.js b/src/core/Create.js index a43f38d46..5dcacf9f0 100644 --- a/src/core/Create.js +++ b/src/core/Create.js @@ -25,17 +25,17 @@ Phaser.Create = function (game) { /** * @property {Phaser.BitmapData} bmd - The internal BitmapData Create uses to generate textures from. */ - this.bmd = game.make.bitmapData(); + this.bmd = null; /** * @property {HTMLCanvasElement} canvas - The canvas the BitmapData uses. */ - this.canvas = this.bmd.canvas; + this.canvas = null; /** * @property {CanvasRenderingContext2D} context - The 2d context of the canvas. */ - this.ctx = this.bmd.context; + this.ctx = null; /** * @property {array} palettes - A range of 16 color palettes for use with sprite generation. @@ -127,6 +127,14 @@ Phaser.Create.prototype = { var w = data[0].length * pixelWidth; var h = data.length * pixelHeight; + // No bmd? Let's make one + if (this.bmd === null) + { + this.bmd = game.make.bitmapData(); + this.canvas = this.bmd.canvas; + this.ctx = this.bmd.context; + } + this.bmd.resize(w, h); this.bmd.clear(); @@ -165,6 +173,14 @@ Phaser.Create.prototype = { */ grid: function (key, width, height, cellWidth, cellHeight, color) { + // No bmd? Let's make one + if (this.bmd === null) + { + this.bmd = game.make.bitmapData(); + this.canvas = this.bmd.canvas; + this.ctx = this.bmd.context; + } + this.bmd.resize(width, height); this.ctx.fillStyle = color;