Skip to content

Commit a2d3956

Browse files
committed
GameObjects.Shape.Grid would render a white fill even if you passed undefined as the fill color in the constructor. It now doesn't render cells if no fill color is given.
1 parent 1b6dfaf commit a2d3956

1 file changed

Lines changed: 17 additions & 24 deletions

File tree

src/gameobjects/shape/grid/Grid.js

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ var GridRender = require('./GridRender');
1414
* treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling
1515
* it for input or physics. It provides a quick and easy way for you to render this shape in your
1616
* game without using a texture, while still taking advantage of being fully batched in WebGL.
17-
*
17+
*
1818
* This shape supports only fill colors and cannot be stroked.
19-
*
19+
*
2020
* A Grid Shape allows you to display a grid in your game, where you can control the size of the
2121
* grid as well as the width and height of the grid cells. You can set a fill color for each grid
2222
* cell as well as an alternate fill color. When the alternate fill color is set then the grid
@@ -151,32 +151,25 @@ var Grid = new Class({
151151
this.setPosition(x, y);
152152
this.setSize(width, height);
153153

154-
if (fillColor !== undefined)
155-
{
156-
this.setFillStyle(fillColor, fillAlpha);
157-
}
158-
159-
if (outlineFillColor !== undefined)
160-
{
161-
this.setOutlineStyle(outlineFillColor, outlineFillAlpha);
162-
}
154+
this.setFillStyle(fillColor, fillAlpha);
155+
this.setOutlineStyle(outlineFillColor, outlineFillAlpha);
163156

164157
this.updateDisplayOrigin();
165158
},
166159

167160
/**
168161
* Sets the fill color and alpha level the grid cells will use when rendering.
169-
*
170-
* If this method is called with no values then the grid cells will not be rendered,
162+
*
163+
* If this method is called with no values then the grid cells will not be rendered,
171164
* however the grid lines and alternating cells may still be.
172-
*
165+
*
173166
* Also see the `setOutlineStyle` and `setAltFillStyle` methods.
174-
*
167+
*
175168
* This call can be chained.
176169
*
177170
* @method Phaser.GameObjects.Grid#setFillStyle
178171
* @since 3.13.0
179-
*
172+
*
180173
* @param {number} [fillColor] - The color the grid cells will be filled with, i.e. 0xff0000 for red.
181174
* @param {number} [fillAlpha=1] - The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property.
182175
*
@@ -202,16 +195,16 @@ var Grid = new Class({
202195

203196
/**
204197
* Sets the fill color and alpha level that the alternating grid cells will use.
205-
*
198+
*
206199
* If this method is called with no values then alternating grid cells will not be rendered in a different color.
207-
*
200+
*
208201
* Also see the `setOutlineStyle` and `setFillStyle` methods.
209-
*
202+
*
210203
* This call can be chained.
211204
*
212205
* @method Phaser.GameObjects.Grid#setAltFillStyle
213206
* @since 3.13.0
214-
*
207+
*
215208
* @param {number} [fillColor] - The color the alternating grid cells will be filled with, i.e. 0xff0000 for red.
216209
* @param {number} [fillAlpha=1] - The alpha the alternating grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property.
217210
*
@@ -237,17 +230,17 @@ var Grid = new Class({
237230

238231
/**
239232
* Sets the fill color and alpha level that the lines between each grid cell will use.
240-
*
233+
*
241234
* If this method is called with no values then the grid lines will not be rendered at all, however
242235
* the cells themselves may still be if they have colors set.
243-
*
236+
*
244237
* Also see the `setFillStyle` and `setAltFillStyle` methods.
245-
*
238+
*
246239
* This call can be chained.
247240
*
248241
* @method Phaser.GameObjects.Grid#setOutlineStyle
249242
* @since 3.13.0
250-
*
243+
*
251244
* @param {number} [fillColor] - The color the lines between the grid cells will be filled with, i.e. 0xff0000 for red.
252245
* @param {number} [fillAlpha=1] - The alpha the lines between the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property.
253246
*

0 commit comments

Comments
 (0)