mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
The Matter.Mass.centerOfMass
component property now returns the pre-calculated Body centerOfMass
property, which is much more accurate than the previous bounds offset value.
This commit is contained in:
parent
9f012ebf86
commit
53314ca435
1 changed files with 5 additions and 1 deletions
|
@ -51,6 +51,10 @@ var Mass = {
|
|||
|
||||
/**
|
||||
* The body's center of mass.
|
||||
*
|
||||
* Calling this creates a new `Vector2 each time to avoid mutation.
|
||||
*
|
||||
* If you only need to read the value and won't change it, you can get it from `GameObject.body.centerOfMass`.
|
||||
*
|
||||
* @name Phaser.Physics.Matter.Components.Mass#centerOfMass
|
||||
* @type {Phaser.Math.Vector2}
|
||||
|
@ -63,7 +67,7 @@ var Mass = {
|
|||
|
||||
get: function ()
|
||||
{
|
||||
return new Vector2(this.body.render.sprite.xOffset * this.width, this.body.render.sprite.yOffset * this.height);
|
||||
return new Vector2(this.body.centerOfMass.x, this.body.centerOfMass.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue