titmael Posted April 30, 2014 Share Posted April 30, 2014 Hi, I use P2 and when I want to add a circle shape for collision to my sprite, they don't share the same center point and of course it mess up my game. Here is the code I use :this.starsCollisionGroup = game.physics.p2.createCollisionGroup();this.bonusesCollisionGroup = game.physics.p2.createCollisionGroup();[...]this.bonusGroup = game.add.group();this.bonusGroup.createMultiple(5, 'bonus_meteor');this.bonusGroup.enableBody = true;this.bonusGroup.physicsBodyType = Phaser.Physics.P2JS;[...]var bonus = this.bonusGroup.getFirstDead();game.physics.p2.enable(bonus, true);bonus.body.setCircle(22);bonus.body.setCollisionGroup(this.bonusesCollisionGroup);bonus.body.collides([this.meteor.collisionGroup]);bonus.body.velocity.y = -600 * this.speed;bonus.body.collideWorldBounds = false;bonus.checkWorldBounds = true;bonus.outOfBoundsKill = true;I don't see anything to explain that behavior. Any idea ? Thanks Link to comment Share on other sites More sharing options...
titmael Posted April 30, 2014 Author Share Posted April 30, 2014 Tadaaaaaaaaaaaaaaaaa ! In fact the gap was from velocity applied to the body.I just hacked my code to manually move the sprite in the update. If you have anything to properly fix that would be nice, I prefer velocity to manual mouve. Link to comment Share on other sites More sharing options...
Recommended Posts