Skip to content

Commit bc41860

Browse files
committed
added getter for center of mass
1 parent 4719694 commit bc41860

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

  • src/physics/matter-js/components

src/physics/matter-js/components/Mass.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
var Body = require('../lib/body/Body');
8+
var Vector2 = require('../../../math/Vector2');
89

910
/**
1011
* [description]
@@ -46,6 +47,14 @@ var Mass = {
4647
Body.setDensity(this.body, value);
4748

4849
return this;
50+
},
51+
52+
centerOfMass: {
53+
54+
get: function ()
55+
{
56+
return new Vector2(this.body.render.sprite.xOffset * this.width, this.body.render.sprite.yOffset * this.height);
57+
}
4958
}
5059

5160
};

0 commit comments

Comments
 (0)