added getter for center of mass

This commit is contained in:
Joachim Grill 2018-06-01 13:26:25 +02:00
parent 4719694f33
commit bc4186061c

View file

@ -5,6 +5,7 @@
*/
var Body = require('../lib/body/Body');
var Vector2 = require('../../../math/Vector2');
/**
* [description]
@ -46,6 +47,14 @@ var Mass = {
Body.setDensity(this.body, value);
return this;
},
centerOfMass: {
get: function ()
{
return new Vector2(this.body.render.sprite.xOffset * this.width, this.body.render.sprite.yOffset * this.height);
}
}
};