valueerror Posted April 28, 2014 Share Posted April 28, 2014 if this is even possible how do i accomplish this?thx in advance! Link to comment Share on other sites More sharing options...
BigRob154 Posted April 28, 2014 Share Posted April 28, 2014 Did you looked into body's shapeOffsets? /** * The local shape offsets, relative to the body center of mass. This is an * array of Array. * @property shapeOffsets * @type {Array} */ this.shapeOffsets = [];I started to look into Phaser's source, there you'll find lot of answers in general. Link to comment Share on other sites More sharing options...
valueerror Posted April 28, 2014 Author Share Posted April 28, 2014 i often browse the source hoping to find answers.. i also read the p2 documentation.. but even if i found something like this.shapeOffsets = []; i wouldn't know how to use it.. Link to comment Share on other sites More sharing options...
BigRob154 Posted April 29, 2014 Share Posted April 29, 2014 "shapeOffsets" is an array of points which describes each shape's offset from the sprite, as far as I know.// pseudo codeshapeOffsets = [[shape1_x, shape1_y], [shape2_x, shape2_y]];When you want to change the shape's offset without creating new geometry you need to change these offsets, imho.Otherwise just ask @schteppe, he's the creator of P2.js. Link to comment Share on other sites More sharing options...
valueerror Posted April 29, 2014 Author Share Posted April 29, 2014 thank you very much.. i decided to delete and recreate the circle instead of changing radius and offset of the existing circle.even if it's more expensive.. Link to comment Share on other sites More sharing options...
valueerror Posted June 29, 2014 Author Share Posted June 29, 2014 push* once again i ran into this problem.. can't be that i can change the size of the shape on the fly but not it's offset.. does anyone know how this is done or.. if this can be done? Link to comment Share on other sites More sharing options...
wayfinder Posted June 29, 2014 Share Posted June 29, 2014 As far as I can tell, you need to supply shapeOffsets with a p2 vec2, and you may need to update the AABB and bounding radius after you change the offset. I haven't tested this myself, but this should be the correct way: var myOffset = p2.vec2.fromValues(-1, -1); // this creates a vector that points 20 px to the right and 20 px downp2body.shapeOffsets[0] = myOffset; // this assigns the vector to the first shape's shapeOffset. note that this is a property of the p2body (so phaserbody.data)p2body.updateAABB();p2body.updateBoundingRadius(); Link to comment Share on other sites More sharing options...
Recommended Posts