You can now pass an existing Game Object to Impact Physics and have it add a body to it.

This commit is contained in:
Richard Davey 2018-01-08 22:16:14 +00:00
parent 86f112aef9
commit f7a1c6fec7

View file

@ -19,6 +19,21 @@ var Factory = new Class({
return new ImpactBody(this.world, x, y, width, height);
},
existing: function (gameObject)
{
var x = gameObject.x - gameObject.frame.centerX;
var y = gameObject.y - gameObject.frame.centerY;
var w = gameObject.width;
var h = gameObject.height;
gameObject.body = this.world.create(x, y, w, h);
gameObject.body.parent = gameObject;
gameObject.body.gameObject = gameObject;
return gameObject;
},
image: function (x, y, key, frame)
{
var image = new ImpactImage(this.world, x, y, key, frame);