JAVASCRIPT   11

Bounce.js

Guest on 30th May 2021 09:54:35 PM

  1. /**
  2.  * @author       Richard Davey <rich@photonstorm.com>
  3.  * @copyright    2020 Photon Storm Ltd.
  4.  * @license      {@link https://opensource.org/licenses/MIT|MIT License}
  5.  */
  6.  
  7. /**
  8.  * A component to set restitution on objects.
  9.  *
  10.  * @namespace Phaser.Physics.Matter.Components.Bounce
  11.  * @since 3.0.0
  12.  */
  13. var Bounce = {
  14.  
  15.     /**
  16.      * Sets the restitution on the physics object.
  17.      *
  18.      * @method Phaser.Physics.Matter.Components.Bounce#setBounce
  19.      * @since 3.0.0
  20.      *
  21.      * @param {number} value - A Number that defines the restitution (elasticity) of the body. The value is always positive and is in the range (0, 1). A value of 0 means collisions may be perfectly inelastic and no bouncing may occur. A value of 0.8 means the body may bounce back with approximately 80% of its kinetic energy. Note that collision response is based on pairs of bodies, and that restitution values are combined with the following formula: `Math.max(bodyA.restitution, bodyB.restitution)`
  22.      *
  23.      * @return {Phaser.GameObjects.GameObject} This Game Object.
  24.      */
  25.     setBounce: function (value)
  26.     {
  27.         this.body.restitution = value;
  28.  
  29.         return this;
  30.     }
  31.  
  32. };
  33.  
  34. module.exports = Bounce;

Raw Paste


Login or Register to edit or fork this paste. It's free.