/
Sensor.js
48 lines (42 loc) · 1.23 KB
/
Sensor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013-2023 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Enables a Matter-enabled Game Object to be a sensor. Should be used as a mixin and not directly.
*
* @namespace Phaser.Physics.Matter.Components.Sensor
* @since 3.0.0
*/
var Sensor = {
/**
* Set the body belonging to this Game Object to be a sensor.
* Sensors trigger collision events, but don't react with colliding body physically.
*
* @method Phaser.Physics.Matter.Components.Sensor#setSensor
* @since 3.0.0
*
* @param {boolean} value - `true` to set the body as a sensor, or `false` to disable it.
*
* @return {this} This Game Object instance.
*/
setSensor: function (value)
{
this.body.isSensor = value;
return this;
},
/**
* Is the body belonging to this Game Object a sensor or not?
*
* @method Phaser.Physics.Matter.Components.Sensor#isSensor
* @since 3.0.0
*
* @return {boolean} `true` if the body is a sensor, otherwise `false`.
*/
isSensor: function ()
{
return this.body.isSensor;
}
};
module.exports = Sensor;