Skip to content

Commit f7a1c6f

Browse files
committed
You can now pass an existing Game Object to Impact Physics and have it add a body to it.
1 parent 86f112a commit f7a1c6f

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

v3/src/physics/impact/Factory.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ var Factory = new Class({
1919
return new ImpactBody(this.world, x, y, width, height);
2020
},
2121

22+
existing: function (gameObject)
23+
{
24+
var x = gameObject.x - gameObject.frame.centerX;
25+
var y = gameObject.y - gameObject.frame.centerY;
26+
var w = gameObject.width;
27+
var h = gameObject.height;
28+
29+
gameObject.body = this.world.create(x, y, w, h);
30+
31+
gameObject.body.parent = gameObject;
32+
gameObject.body.gameObject = gameObject;
33+
34+
return gameObject;
35+
},
36+
2237
image: function (x, y, key, frame)
2338
{
2439
var image = new ImpactImage(this.world, x, y, key, frame);

0 commit comments

Comments
 (0)