lonelydatum Posted July 2, 2014 Share Posted July 2, 2014 Hi there, I'm trying to get the width and height from the returned body:var body = this.game.physics.p2.convertCollisionObjects(map, "floorMiddle")[0]; It would be great if this was possible: body.widthbody.height And, unfortunately the body.sprite=null otherwise I'd just access the sprite info. Thanks,Gar Link to comment Share on other sites More sharing options...
wayfinder Posted July 2, 2014 Share Posted July 2, 2014 You could try working it out from body.data.aabb.lowerBound and body.data.aabb.upperBound edit: body.width = this.physics.p2.mpx(body.data.aabb.upperBound[0] - body.data.aabb.lowerBound[0]);body.height = this.physics.p2.mpx(body.data.aabb.upperBound[1] - body.data.aabb.lowerBound[1]); lonelydatum 1 Link to comment Share on other sites More sharing options...
lonelydatum Posted July 3, 2014 Author Share Posted July 3, 2014 @wayfinder, thanks for pointing me in the right direction! I first needed to update the aabb Float32Array: body.data.aabb.updateAABB();var width = this.game.physics.p2.mpx(body.data.aabb.upperBound[0] - body.data.aabb.lowerBound[0]);var height = this.game.physics.p2.mpx(body.data.aabb.upperBound[1] - body.data.aabb.lowerBound[1]); Otherwise the upperbounds/lowerbounds were always equal to zero. Link to comment Share on other sites More sharing options...
Recommended Posts