2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2019-01-15 16:20:22 +00:00
|
|
|
* @copyright 2019 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
|
|
|
*/
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
2018-09-28 11:19:21 +00:00
|
|
|
* The Impact Set Game Object component.
|
|
|
|
* Should be applied as a mixin.
|
2018-02-09 01:40:41 +00:00
|
|
|
*
|
2019-02-12 15:01:54 +00:00
|
|
|
* @namespace Phaser.Physics.Impact.Components.SetGameObject
|
2018-02-09 01:40:41 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-08-17 00:21:01 +00:00
|
|
|
var SetGameObject = {
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Impact.Components.SetGameObject#setGameObject
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-03-18 23:42:09 +00:00
|
|
|
* @param {Phaser.GameObjects.GameObject} gameObject - [description]
|
|
|
|
* @param {boolean} [sync=true] - [description]
|
2018-02-09 01:40:41 +00:00
|
|
|
*
|
2018-03-18 23:42:09 +00:00
|
|
|
* @return {Phaser.GameObjects.GameObject} This Game Object.
|
2018-02-09 01:40:41 +00:00
|
|
|
*/
|
2017-08-17 05:00:38 +00:00
|
|
|
setGameObject: function (gameObject, sync)
|
2017-08-17 00:21:01 +00:00
|
|
|
{
|
2017-08-17 05:00:38 +00:00
|
|
|
if (sync === undefined) { sync = true; }
|
2017-08-17 00:21:01 +00:00
|
|
|
|
|
|
|
if (gameObject)
|
|
|
|
{
|
|
|
|
this.body.gameObject = gameObject;
|
|
|
|
|
2017-08-17 05:00:38 +00:00
|
|
|
if (sync)
|
2017-08-17 00:21:01 +00:00
|
|
|
{
|
2017-08-17 05:00:38 +00:00
|
|
|
this.syncGameObject();
|
2017-08-17 00:21:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.body.gameObject = null;
|
|
|
|
}
|
|
|
|
|
2017-08-17 05:00:38 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Impact.Components.SetGameObject#syncGameObject
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-03-18 23:42:09 +00:00
|
|
|
* @return {Phaser.GameObjects.GameObject} This Game Object.
|
2018-02-09 01:40:41 +00:00
|
|
|
*/
|
2017-08-17 05:00:38 +00:00
|
|
|
syncGameObject: function ()
|
|
|
|
{
|
|
|
|
var gameObject = this.body.gameObject;
|
|
|
|
|
|
|
|
if (gameObject)
|
|
|
|
{
|
|
|
|
this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY);
|
|
|
|
}
|
|
|
|
|
2017-08-17 00:21:01 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = SetGameObject;
|