Jump to content

How do i detect a collision on a rotating rect sprite?


Recommended Posts

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


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...