frozenthrone Posted May 28, 2014 Share Posted May 28, 2014 I am a newbie to game dev and Phaser. My scenario is this. I have a rectangular sprite(Initial angle 0 degrees) that rotates about its base. There is another rectangular sprite below it which gets overlapped by the rotating sprite at each rotation. Collision without rotation works for me. But I am unable to detect the collision when the first sprite rotates. Please help me sort this issue. I use arcade physics. My code is below.function create() { sprite1 = game.add.sprite(100, 100, "sprite1"); sprite1 = game.add.sprite(100, 150, "sprite1"); game.physics.enable(sprite1, Phaser.Physics.ARCADE); game.physics.enable(sprite2, Phaser.Physics.ARCADE); }function update() { sprite1.angle += 1; game.physics.arcade.collide(sprite1, sprite2, collisionHandler, null, this);}function collisionHandler(obj1, obj2){ console.log("Collided");} Link to comment Share on other sites More sharing options...
rich Posted May 28, 2014 Share Posted May 28, 2014 Arcade Physics is an AABB based physics system, i.e. non-rotating, axis aligned rectangles. If you need to support rotating rects like that you'll have to use P2. WombatTurkey 1 Link to comment Share on other sites More sharing options...
frozenthrone Posted May 28, 2014 Author Share Posted May 28, 2014 Thank you rich for your reply. I find that there is no overlap detection function for p2 bodies just like we have in Arcade. Is there any solution to find just if the rects overlap? Tilde 1 Link to comment Share on other sites More sharing options...
Recommended Posts