Skip to content

Commit 24efda7

Browse files
committed
Add allowDrag, allowGravity, allowRotation to PhysicsGroup config
1 parent 4741ee0 commit 24efda7

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

src/physics/arcade/Body.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,60 @@ var Body = new Class({
15931593
return this;
15941594
},
15951595

1596+
/**
1597+
* Enables or disables drag.
1598+
*
1599+
* @method Phaser.Physics.Arcade.Body#setAllowDrag
1600+
* @since 3.9.0
1601+
* @see Phaser.Physics.Arcade.Body#allowDrag
1602+
*
1603+
* @param {boolean} val - The value of `allowDrag`.
1604+
*
1605+
* @return {Phaser.Physics.Arcade.Body} This Body object.
1606+
*/
1607+
setAllowDrag: function (val)
1608+
{
1609+
this.allowDrag = val;
1610+
1611+
return this;
1612+
},
1613+
1614+
/**
1615+
* Enables or disables gravity's effect on this Body.
1616+
*
1617+
* @method Phaser.Physics.Arcade.Body#setAllowGravity
1618+
* @since 3.9.0
1619+
* @see Phaser.Physics.Arcade.Body#allowGravity
1620+
*
1621+
* @param {boolean} val - The value of `allowGravity`.
1622+
*
1623+
* @return {Phaser.Physics.Arcade.Body} This Body object.
1624+
*/
1625+
setAllowGravity: function (val)
1626+
{
1627+
this.allowGravity = val;
1628+
1629+
return this;
1630+
},
1631+
1632+
/**
1633+
* Enables or disables rotation.
1634+
*
1635+
* @method Phaser.Physics.Arcade.Body#setAllowRotation
1636+
* @since 3.9.0
1637+
* @see Phaser.Physics.Arcade.Body#allowRotation
1638+
*
1639+
* @param {boolean} val - The value of `allowRotation`.
1640+
*
1641+
* @return {Phaser.Physics.Arcade.Body} This Body object.
1642+
*/
1643+
setAllowRotation: function (val)
1644+
{
1645+
this.allowRotation = val;
1646+
1647+
return this;
1648+
},
1649+
15961650
/**
15971651
* Sets the Body's drag.
15981652
*

src/physics/arcade/PhysicsGroup.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ var Group = require('../../gameobjects/group/Group');
1717
* @property {boolean} [collideWorldBounds=false] - Sets {@link Phaser.Physics.Arcade.Body#collideWorldBounds}.
1818
* @property {number} [accelerationX=0] - Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.x}.
1919
* @property {number} [accelerationY=0] - Sets {@link Phaser.Physics.Arcade.Body#acceleration acceleration.y}.
20+
* @property {boolean} [allowDrag=true] - Sets {@link Phaser.Physics.Arcade.Body#allowDrag}.
21+
* @property {boolean} [allowGravity=true] - Sets {@link Phaser.Physics.Arcade.Body#allowGravity}.
22+
* @property {boolean} [allowRotation=true] - Sets {@link Phaser.Physics.Arcade.Body#allowRotation}.
2023
* @property {number} [bounceX=0] - Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.x}.
2124
* @property {number} [bounceY=0] - Sets {@link Phaser.Physics.Arcade.Body#bounce bounce.y}.
2225
* @property {number} [dragX=0] - Sets {@link Phaser.Physics.Arcade.Body#drag drag.x}.
@@ -40,6 +43,9 @@ var Group = require('../../gameobjects/group/Group');
4043
* @property {boolean} setCollideWorldBounds - [description]
4144
* @property {number} setAccelerationX - [description]
4245
* @property {number} setAccelerationY - [description]
46+
* @property {boolean} setAllowDrag - [description]
47+
* @property {boolean} setAllowGravity - [description]
48+
* @property {boolean} setAllowRotation - [description]
4349
* @property {number} setBounceX - [description]
4450
* @property {number} setBounceY - [description]
4551
* @property {number} setDragX - [description]
@@ -133,6 +139,9 @@ var PhysicsGroup = new Class({
133139
setCollideWorldBounds: GetFastValue(config, 'collideWorldBounds', false),
134140
setAccelerationX: GetFastValue(config, 'accelerationX', 0),
135141
setAccelerationY: GetFastValue(config, 'accelerationY', 0),
142+
setAllowDrag: GetFastValue(config, 'allowDrag', true),
143+
setAllowGravity: GetFastValue(config, 'allowGravity', true),
144+
setAllowRotation: GetFastValue(config, 'allowRotation', true),
136145
setBounceX: GetFastValue(config, 'bounceX', 0),
137146
setBounceY: GetFastValue(config, 'bounceY', 0),
138147
setDragX: GetFastValue(config, 'dragX', 0),

0 commit comments

Comments
 (0)