diff --git a/src/physics/matter-js/components/Mass.js b/src/physics/matter-js/components/Mass.js index 1269cb1b5..2574ca3db 100644 --- a/src/physics/matter-js/components/Mass.js +++ b/src/physics/matter-js/components/Mass.js @@ -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); } }