2018-01-16 22:28:29 +00:00
|
|
|
var GameObjectCreator = require('../GameObjectCreator');
|
2017-09-14 01:27:29 +00:00
|
|
|
var GetAdvancedValue = require('../../utils/object/GetAdvancedValue');
|
|
|
|
var Zone = require('./Zone');
|
|
|
|
|
2018-02-06 16:15:22 +00:00
|
|
|
/**
|
|
|
|
* Creates a new Zone Game Object and returns it.
|
|
|
|
*
|
|
|
|
* Note: This method will only be available if the Zone Game Object has been built into Phaser.
|
|
|
|
*
|
|
|
|
* @method Phaser.GameObjects.GameObjectCreator#zone
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
|
|
|
* @param {object} config - [description]
|
|
|
|
*
|
|
|
|
* @return {Phaser.GameObjects.Zone} The Game Object that was created.
|
|
|
|
*/
|
2017-09-14 01:27:29 +00:00
|
|
|
GameObjectCreator.register('zone', function (config)
|
|
|
|
{
|
|
|
|
var x = GetAdvancedValue(config, 'x', 0);
|
|
|
|
var y = GetAdvancedValue(config, 'y', 0);
|
|
|
|
var width = GetAdvancedValue(config, 'width', 1);
|
|
|
|
var height = GetAdvancedValue(config, 'height', width);
|
|
|
|
|
|
|
|
return new Zone(this.scene, x, y, width, height);
|
|
|
|
});
|
2018-02-06 16:15:22 +00:00
|
|
|
|
|
|
|
// When registering a factory function 'this' refers to the GameObjectCreator context.
|