mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 04:33:31 +00:00
Physics.Arcade.Body.setDamping
is a new method that allows you to set the useDamping
property of a Body in a chainable way. Fix #5352
This commit is contained in:
parent
7a849e249d
commit
675e43350d
1 changed files with 25 additions and 0 deletions
|
@ -2072,6 +2072,31 @@ var Body = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* If this Body is using `drag` for deceleration this property controls how the drag is applied.
|
||||
* If set to `true` drag will use a damping effect rather than a linear approach. If you are
|
||||
* creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in
|
||||
* the game Asteroids) then you will get a far smoother and more visually correct deceleration
|
||||
* by using damping, avoiding the axis-drift that is prone with linear deceleration.
|
||||
*
|
||||
* If you enable this property then you should use far smaller `drag` values than with linear, as
|
||||
* they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow
|
||||
* deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Body#setDamping
|
||||
* @since 3.50.0
|
||||
*
|
||||
* @param {boolean} value - `true` to use damping, or `false` to use drag.
|
||||
*
|
||||
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
||||
*/
|
||||
setDamping: function (value)
|
||||
{
|
||||
this.useDamping = value;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the Body's horizontal drag.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue