Skip to content

Commit be558d2

Browse files
committed
Scale damping
1 parent 165c908 commit be558d2

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/physics/arcade/Body.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,11 @@ var Body = new Class({
335335
/**
336336
* When `useDamping` is false (the default), this is absolute loss of velocity due to movement, in pixels per second squared.
337337
*
338-
* When `useDamping` is true, this is 1 minus the damping factor.
338+
* When `useDamping` is true, this is a damping multiplier between 0 and 1.
339+
* A value of 0 means the Body stops instantly.
340+
* A value of 0.01 mean the Body loses 99% of its velocity per second.
341+
* A value of 0.1 means the Body loses 90% of its velocity per second.
339342
* A value of 1 means the Body loses no velocity.
340-
* A value of 0.95 means the Body loses 5% of its velocity per step.
341-
* A value of 0.5 means the Body loses 50% of its velocity per step.
342343
*
343344
* The x and y components are applied separately.
344345
*
@@ -486,8 +487,8 @@ var Body = new Class({
486487
* by using damping, avoiding the axis-drift that is prone with linear deceleration.
487488
*
488489
* If you enable this property then you should use far smaller `drag` values than with linear, as
489-
* they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow
490-
* deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately.
490+
* they are used as a multiplier on the velocity. Values such as 0.05 will give a nice slow
491+
* deceleration.
491492
*
492493
* @name Phaser.Physics.Arcade.Body#useDamping
493494
* @type {boolean}

src/physics/arcade/World.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,7 @@ var World = new Class({
12481248
if (useDamping)
12491249
{
12501250
// Damping based deceleration
1251+
dragX = Math.pow(dragX, delta);
12511252

12521253
velocityX *= dragX;
12531254

@@ -1287,6 +1288,8 @@ var World = new Class({
12871288
if (useDamping)
12881289
{
12891290
// Damping based deceleration
1291+
dragY = Math.pow(dragY, delta);
1292+
12901293
velocityY *= dragY;
12911294

12921295
speed = Math.sqrt(velocityX * velocityX + velocityY * velocityY);

0 commit comments

Comments
 (0)