mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 04:33:31 +00:00
You can now pass an existing Game Object to Impact Physics and have it add a body to it.
This commit is contained in:
parent
86f112aef9
commit
f7a1c6fec7
1 changed files with 15 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue