3ddy Posted May 10, 2016 Share Posted May 10, 2016 Hey, I'm using p2 physics and I have a sprite (pixel line) that is rotating around some point (beginning of the line). For rotation I use angularVelocity. To display my sprite correctly I had to set it's anchor to (0,1) and it works fine, but collision box remained where it was before. Please check out my code and attached image game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.setImpactEvents(true); this.obstacle1CollisionGroup = this.game.physics.p2.createCollisionGroup(); this.obstacle = game.add.sprite(700, 400, "line"); this.physics.p2.enable(this.obstacle, true); this.obstacle.body.setCollisionGroup(this.obstacle1CollisionGroup); this.obstacle.anchor.setTo(0,1) this.obstacle.body.angularVelocity = 0.3; this.obstacle.body.angularDamping = 0; Link to comment Share on other sites More sharing options...
3ddy Posted May 11, 2016 Author Share Posted May 11, 2016 I have tried using for example body.offset but nothing seems to work - am I missing something, or I should rotate my object some other way? It needs to rotate around that black dot (beginning of line). The sprite of the line is the size of that rectangle EDIT: SOLVED after more digging: Link to comment Share on other sites More sharing options...
Recommended Posts