I discovered a small but significant problem within the applyDamping function where the velocity would never be set to zero because of an if clause.
Version is 1.1.5.
That is the actual version:
/**
* Internal method that checks the acceleration and applies damping if not set.
*
* @method Phaser.Physics.Arcade.Body#applyDamping
* @protected
*/
applyDamping: function () {
if (this.linearDamping > 0 && this.acceleration.isZero())
{
if (this.speed > this.linearDamping)
{
this.speed -= this.linearDamping;
}
else
{
this.speed = 0;
}
// Don't bother if speed 0
if (this.speed > 0)
{
this.velocity.x = Math.cos(this.angle) * this.speed;
this.velocity.y = Math.sin(this.angle) * this.speed;
this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y);
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
}
}
I've deleted the if clause so now linearDamping is applyed correctly. I don't know how to make merge/pull requests or something so please feel free to change your code.
/**
* Internal method that checks the acceleration and applies damping if not set.
*
* @method Phaser.Physics.Arcade.Body#applyDamping
* @protected
*/
applyDamping: function () {
if (this.linearDamping > 0 && this.acceleration.isZero())
{
if (this.speed > this.linearDamping)
{
this.speed -= this.linearDamping;
}
else
{
this.speed = 0;
}
// actually we need to bother if speed = 0 so velocity can become 0
this.velocity.x = Math.cos(this.angle) * this.speed;
this.velocity.y = Math.sin(this.angle) * this.speed;
this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y);
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
}
},
Hi,
I discovered a small but significant problem within the applyDamping function where the velocity would never be set to zero because of an if clause. Version is 1.1.5.
That is the actual version:
I've deleted the if clause so now linearDamping is applyed correctly. I don't know how to make merge/pull requests or something so please feel free to change your code.