Skip to content

Commit a30d5ac

Browse files
committed
The Graphics Creator would automatically add the Graphics to the display list by mistake. The default should be to remain hidden. Fix phaserjs#3637
1 parent a14ce15 commit a30d5ac

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/gameobjects/graphics/GraphicsCreator.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,21 @@ var Graphics = require('./Graphics');
1616
* @method Phaser.GameObjects.GameObjectCreator#graphics
1717
* @since 3.0.0
1818
*
19-
* @param {object} [config] - [description]
19+
* @param {object} config - The configuration object this Game Object will use to create itself.
20+
* @param {boolean} [addToScene] - Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object.
2021
*
2122
* @return {Phaser.GameObjects.Graphics} The Game Object that was created.
2223
*/
23-
GameObjectCreator.register('graphics', function (config)
24+
GameObjectCreator.register('graphics', function (config, addToScene)
2425
{
25-
var add = GetAdvancedValue(config, 'add', true);
26+
if (addToScene !== undefined)
27+
{
28+
config.add = addToScene;
29+
}
30+
2631
var graphics = new Graphics(this.scene, config);
2732

28-
if (add)
33+
if (config.add)
2934
{
3035
this.scene.sys.displayList.add(graphics);
3136
}

0 commit comments

Comments
 (0)