JAVASCRIPT   7

Static.js

Guest on 31st May 2021 02:28:51 AM

  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. var Body = require('../lib/body/Body');
  8.  
  9. /**
  10.  * Provides methods used for getting and setting the static state of a physics body.
  11.  *
  12.  * @namespace Phaser.Physics.Matter.Components.Static
  13.  * @since 3.0.0
  14.  */
  15. var Static = {
  16.  
  17.     /**
  18.      * Changes the physics body to be either static `true` or dynamic `false`.
  19.      *
  20.      * @method Phaser.Physics.Matter.Components.Static#setStatic
  21.      * @since 3.0.0
  22.      *
  23.      * @param {boolean} value - `true` to set the body as being static, or `false` to make it dynamic.
  24.      *
  25.      * @return {Phaser.GameObjects.GameObject} This Game Object.
  26.      */
  27.     setStatic: function (value)
  28.     {
  29.         Body.setStatic(this.body, value);
  30.  
  31.         return this;
  32.     },
  33.  
  34.     /**
  35.      * Returns `true` if the body is static, otherwise `false` for a dynamic body.
  36.      *
  37.      * @method Phaser.Physics.Matter.Components.Static#isStatic
  38.      * @since 3.0.0
  39.      *
  40.      * @return {boolean} `true` if the body is static, otherwise `false`.
  41.      */
  42.     isStatic: function ()
  43.     {
  44.         return this.body.isStatic;
  45.     }
  46.  
  47. };
  48.  
  49. module.exports = Static;

Raw Paste


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