espace 25 Posted March 13, 2017 Report Share Posted March 13, 2017 hi, i don't see where is my error with this snippet https://jsfiddle.net/espace3d/z2Lvha4j/ i want receive a collision between a object who's rotating and another. if a put my "projectile" on "axe" i receive a notification but nothing with the rotation ??? thanks for your help var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload:preload, create: create,update: update }); function preload() { game.load.image('circle', 'https://s13.postimg.org/xjhlzmiev/disc_png.png'); game.load.image('rect', 'http://s10.postimg.org/6fa6mgrd5/motif.jpg'); } function create() { this.projectile=game.add.sprite(100,400,'circle') this.projectile.touch=function(){ alert('touch') } this.axe=game.add.sprite(200,200,'rect') this.axe.width=300 this.axe.height=10 game.physics.arcade.enable(this.projectile); game.physics.arcade.enable(this.axe); game.physics.startSystem(Phaser.Physics.ARCADE) } function update(){ this.axe.body.rotation += 1; game.physics.arcade.collide(this.axe,this.projectile,this.projectile.touch,null,this) } Quote Link to post Share on other sites
Mattia 12 Posted March 13, 2017 Report Share Posted March 13, 2017 Hi, I've added some debug lines to your code: https://jsfiddle.net/qL2f263y/1/ As you can see the arcade body is not rotating together with the sprite. And, from what I read in the docs, I don't think that it is possible to do so. Quote Please understand that the collision Body itself never rotates, it is always axis-aligned. However these values are passed up to the parent Sprite and updates its rotation. From: http://phaser.io/docs/2.4.4/Phaser.Physics.Arcade.Body.html#rotation Have you tried with P2 physics? Quote Link to post Share on other sites
espace 25 Posted March 13, 2017 Author Report Share Posted March 13, 2017 hi @mattia, thanks for your comment. I had imagined that the problem comes from the fact the body did not turn.I wanted to use arcade physics to use the least possible resource. pity.A question: is it possible to use p2 physics and arcade simultaneously ?Or is it a bad solution and is it better to use only p2? Quote Link to post Share on other sites
espace 25 Posted March 13, 2017 Author Report Share Posted March 13, 2017 it seems that it doesn't works https://jsfiddle.net/0wsf8ht1/ p2 ok but it seems heavy... https://jsfiddle.net/gz85ug60/ Quote Link to post Share on other sites
Mattia 12 Posted March 13, 2017 Report Share Posted March 13, 2017 Oh, I was writing reply but you anticipated me Well, by the way, I've ported your example to P2, give it a look: https://jsfiddle.net/qL2f263y/5/ espace 1 Quote Link to post Share on other sites
espace 25 Posted March 13, 2017 Author Report Share Posted March 13, 2017 oh thanks Quote Link to post Share on other sites
espace 25 Posted March 22, 2017 Author Report Share Posted March 22, 2017 i post an another post about this subject, maybe you could help me... Quote Link to post Share on other sites
Mattia 12 Posted March 24, 2017 Report Share Posted March 24, 2017 Oh, sorry @espace3d I did not read your last comment in time.Btw, I cannot see your other post, have you removed it? Have you already fixed it by yourself? Quote Link to post Share on other sites
espace 25 Posted March 31, 2017 Author Report Share Posted March 31, 2017 Hi, it's strange i didn't receive notification when someone post something on my post... Yes i remove my post and it's also resolved Quote Link to post Share on other sites
Mattia 12 Posted April 1, 2017 Report Share Posted April 1, 2017 I was not receiving notifications neither, I had to change my profile settings. Glad to year that you solved that Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.