phaser/plugins/impact/components/Collides.js

151 lines
3.1 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-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-09-28 11:19:21 +00:00
* The Impact Collides component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Collides
* @since 3.0.0
*/
2017-08-15 22:36:00 +00:00
var Collides = {
_collideCallback: null,
_callbackScope: null,
/**
* [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-03-18 23:42:09 +00:00
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
setCollideCallback: function (callback, scope)
{
this._collideCallback = callback;
if (scope)
{
this._callbackScope = scope;
}
return this;
},
/**
* [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.
*/
2017-08-15 22:36:00 +00:00
setCollidesNever: function ()
{
this.body.collides = COLLIDES.NEVER;
return this;
},
/**
* [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-03-18 23:42:09 +00:00
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
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;
},
/**
* [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-03-18 23:42:09 +00:00
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
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;
},
/**
* [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-03-18 23:42:09 +00:00
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
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;
},
/**
* [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-03-18 23:42:09 +00:00
* @return {Phaser.GameObjects.GameObject} This Game Object.
*/
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;
},
/**
* [description]
*
* @name Phaser.Physics.Impact.Components.Collides#collides
2018-03-18 23:42:09 +00:00
* @type {number}
* @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;