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-08-15 22:36:00 +00:00
|
|
|
var COLLIDES = require('../COLLIDES');
|
|
|
|
|
2018-03-19 21:57:46 +00:00
|
|
|
/**
|
|
|
|
* @callback CollideCallback
|
|
|
|
*
|
|
|
|
* @param {Phaser.Physics.Impact.Body} body - [description]
|
|
|
|
* @param {Phaser.Physics.Impact.Body} other - [description]
|
|
|
|
* @param {string} axis - [description]
|
|
|
|
*/
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
2018-09-28 11:19:21 +00:00
|
|
|
* The Impact Collides 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.Collides
|
2018-02-09 01:40:41 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-08-15 22:36:00 +00:00
|
|
|
var Collides = {
|
|
|
|
|
2017-08-16 16:15:58 +00:00
|
|
|
_collideCallback: null,
|
|
|
|
_callbackScope: null,
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Impact.Components.Collides#setCollideCallback
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-03-19 21:57:46 +00:00
|
|
|
* @param {CollideCallback} callback - [description]
|
2018-03-21 13:15:25 +00:00
|
|
|
* @param {*} scope - [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-16 16:15:58 +00:00
|
|
|
setCollideCallback: function (callback, scope)
|
|
|
|
{
|
|
|
|
this._collideCallback = callback;
|
|
|
|
|
|
|
|
if (scope)
|
|
|
|
{
|
|
|
|
this._callbackScope = scope;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Impact.Components.Collides#setCollidesNever
|
|
|
|
* @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-15 22:36:00 +00:00
|
|
|
setCollidesNever: function ()
|
|
|
|
{
|
|
|
|
this.body.collides = COLLIDES.NEVER;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
2018-04-18 12:29:22 +00:00
|
|
|
* @method Phaser.Physics.Impact.Components.Collides#setLiteCollision
|
2018-04-19 13:45:45 +00:00
|
|
|
* @since 3.6.0
|
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
|
|
|
*/
|
2018-04-18 12:29:22 +00:00
|
|
|
setLiteCollision: function ()
|
2017-08-15 22:36:00 +00:00
|
|
|
{
|
|
|
|
this.body.collides = COLLIDES.LITE;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
2018-04-18 12:29:22 +00:00
|
|
|
* @method Phaser.Physics.Impact.Components.Collides#setPassiveCollision
|
2018-04-19 13:45:45 +00:00
|
|
|
* @since 3.6.0
|
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
|
|
|
*/
|
2018-04-18 12:29:22 +00:00
|
|
|
setPassiveCollision: function ()
|
2017-08-15 22:36:00 +00:00
|
|
|
{
|
|
|
|
this.body.collides = COLLIDES.PASSIVE;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
2018-04-18 12:29:22 +00:00
|
|
|
* @method Phaser.Physics.Impact.Components.Collides#setActiveCollision
|
2018-04-19 13:45:45 +00:00
|
|
|
* @since 3.6.0
|
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
|
|
|
*/
|
2018-04-18 12:29:22 +00:00
|
|
|
setActiveCollision: function ()
|
2017-08-15 22:36:00 +00:00
|
|
|
{
|
|
|
|
this.body.collides = COLLIDES.ACTIVE;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
2018-04-18 12:29:22 +00:00
|
|
|
* @method Phaser.Physics.Impact.Components.Collides#setFixedCollision
|
2018-04-19 13:45:45 +00:00
|
|
|
* @since 3.6.0
|
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
|
|
|
*/
|
2018-04-18 12:29:22 +00:00
|
|
|
setFixedCollision: function ()
|
2017-08-15 22:36:00 +00:00
|
|
|
{
|
|
|
|
this.body.collides = COLLIDES.FIXED;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
|
|
|
* [description]
|
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Impact.Components.Collides#collides
|
2018-03-18 23:42:09 +00:00
|
|
|
* @type {number}
|
2018-02-09 01:40:41 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-08-15 22:36:00 +00:00
|
|
|
collides: {
|
|
|
|
|
|
|
|
get: function ()
|
|
|
|
{
|
|
|
|
return this.body.collides;
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value)
|
|
|
|
{
|
|
|
|
this.body.collides = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Collides;
|