phaser/src/gameobjects/graphics/GraphicsFactory.js

34 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2020-01-15 12:07:09 +00:00
* @copyright 2020 Photon Storm Ltd.
2019-05-10 15:15:04 +00:00
* @license {@link https://opensource.org/licenses/MIT|MIT License}
2018-02-12 16:01:20 +00:00
*/
2017-02-28 14:49:39 +00:00
var Graphics = require('./Graphics');
var GameObjectFactory = require('../GameObjectFactory');
2017-02-28 14:49:39 +00:00
2018-02-06 00:56:09 +00:00
/**
* Creates a new Graphics Game Object and adds it to the Scene.
*
* Note: This method will only be available if the Graphics Game Object has been built into Phaser.
*
* @method Phaser.GameObjects.GameObjectFactory#graphics
* @since 3.0.0
*
2019-05-09 10:55:40 +00:00
* @param {Phaser.Types.GameObjects.Graphics.Options} [config] - The Graphics configuration.
*
2018-02-06 00:56:09 +00:00
* @return {Phaser.GameObjects.Graphics} The Game Object that was created.
*/
GameObjectFactory.register('graphics', function (config)
{
return this.displayList.add(new Graphics(this.scene, config));
});
// When registering a factory function 'this' refers to the GameObjectFactory context.
//
// There are several properties available to use:
//
// this.scene - a reference to the Scene that owns the GameObjectFactory
// this.displayList - a reference to the Display List the Scene owns
// this.updateList - a reference to the Update List the Scene owns