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 Bounce 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.Bounce
|
2018-02-09 01:40:41 +00:00
|
|
|
* @since 3.0.0
|
|
|
|
*/
|
2017-08-15 22:36:00 +00:00
|
|
|
var Bounce = {
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
2018-09-28 11:19:21 +00:00
|
|
|
* Sets the impact physics bounce, or restitution, value.
|
2018-02-09 01:40:41 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Impact.Components.Bounce#setBounce
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-09-28 11:19:21 +00:00
|
|
|
* @param {number} value - A value between 0 (no rebound) and 1 (full rebound)
|
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-15 22:36:00 +00:00
|
|
|
setBounce: function (value)
|
|
|
|
{
|
|
|
|
this.body.bounciness = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
2018-09-28 11:19:21 +00:00
|
|
|
* Sets the minimum velocity the body is allowed to be moving to be considered for rebound.
|
2018-02-09 01:40:41 +00:00
|
|
|
*
|
|
|
|
* @method Phaser.Physics.Impact.Components.Bounce#setMinBounceVelocity
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-09-28 11:19:21 +00:00
|
|
|
* @param {number} value - The minimum allowed velocity.
|
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-15 23:30:12 +00:00
|
|
|
setMinBounceVelocity: function (value)
|
|
|
|
{
|
|
|
|
this.body.minBounceVelocity = value;
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2018-02-09 01:40:41 +00:00
|
|
|
/**
|
2018-09-28 11:19:21 +00:00
|
|
|
* The bounce, or restitution, value of this body.
|
|
|
|
* A value between 0 (no rebound) and 1 (full rebound)
|
2018-02-09 01:40:41 +00:00
|
|
|
*
|
|
|
|
* @name Phaser.Physics.Impact.Components.Bounce#bounce
|
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 23:30:12 +00:00
|
|
|
bounce: {
|
2017-08-15 22:36:00 +00:00
|
|
|
|
|
|
|
get: function ()
|
|
|
|
{
|
|
|
|
return this.body.bounciness;
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value)
|
|
|
|
{
|
|
|
|
this.body.bounciness = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Bounce;
|