@@ -25,17 +25,17 @@ Phaser.Create = function (game) {
2525 /**
2626 * @property {Phaser.BitmapData } bmd - The internal BitmapData Create uses to generate textures from.
2727 */
28- this . bmd = game . make . bitmapData ( ) ;
28+ this . bmd = null ;
2929
3030 /**
3131 * @property {HTMLCanvasElement } canvas - The canvas the BitmapData uses.
3232 */
33- this . canvas = this . bmd . canvas ;
33+ this . canvas = null ;
3434
3535 /**
3636 * @property {CanvasRenderingContext2D } context - The 2d context of the canvas.
3737 */
38- this . ctx = this . bmd . context ;
38+ this . ctx = null ;
3939
4040 /**
4141 * @property {array } palettes - A range of 16 color palettes for use with sprite generation.
@@ -127,6 +127,14 @@ Phaser.Create.prototype = {
127127 var w = data [ 0 ] . length * pixelWidth ;
128128 var h = data . length * pixelHeight ;
129129
130+ // No bmd? Let's make one
131+ if ( this . bmd === null )
132+ {
133+ this . bmd = game . make . bitmapData ( ) ;
134+ this . canvas = this . bmd . canvas ;
135+ this . ctx = this . bmd . context ;
136+ }
137+
130138 this . bmd . resize ( w , h ) ;
131139 this . bmd . clear ( ) ;
132140
@@ -165,6 +173,14 @@ Phaser.Create.prototype = {
165173 */
166174 grid : function ( key , width , height , cellWidth , cellHeight , color ) {
167175
176+ // No bmd? Let's make one
177+ if ( this . bmd === null )
178+ {
179+ this . bmd = game . make . bitmapData ( ) ;
180+ this . canvas = this . bmd . canvas ;
181+ this . ctx = this . bmd . context ;
182+ }
183+
168184 this . bmd . resize ( width , height ) ;
169185
170186 this . ctx . fillStyle = color ;
0 commit comments