lundi 13 avril 2015

Javascript Hittest Rotation


Vote count:

0




Hi stackoverflow community,


I am trying to get the hittest working while having a rotating object, but I am having a hard time making the collisions detect correctly.


Example of my current work: https://jsfiddle.net/studentlearning110/c2quhdad/21/


The hittest does not work when the object is rotating, and only hits the platform in the original position. How can I resolve this?


The hittest code I tried using is:



if(aX1>bX1 && aX1<bX2 && aY1>bY1 && aY1<bY3) hit = true;
else if(aX2>=bX1 && aX2<=bX2 && aY2>=bY1 && aY2<=bY3) hit = true;
else if(aX3>=bX1 && aX3<=bX2 && aY3>=bY1 && aY3<=bY3) hit = true;
else if(aX4>=bX1 && aX4<=bX2 && aY4>=bY1 && aY4<=bY3) hit = true;
else if(bX1>=aX1 && bX1<=aX2 && bY1>=aY1 && bY1<=aY3) hit = true;
else if(bX2>=aX1 && bX2<=aX2 && bY2>=aY1 && bY2<=aY3) hit = true;
else if(bX3>=aX1 && bX3<=aX2 && bY3>=aY1 && bY3<=aY3) hit = true;
else if(bX4>=aX1 && bX4<=aX2 && bY4>=aY1 && bY4<=aY3) hit = true;


Thank you very much



asked 1 min ago







Javascript Hittest Rotation

Aucun commentaire:

Enregistrer un commentaire