I want to detect if one canvas object for example – circle crosses another canvas object
For example I have 2 circles moving
I am using paper.js library
c1 = new Path.Circle([20, 20], 20);
c1.fillColor = 'red';
c2 = c1.clone();
c2.position += 500;
c2.fillColor = 'green';
c = 0;
function onFrame(event){
c += 0.1;
c1.position += c;
c2.position -= c;
}
I want to detect when c1 hits c2
In your
onFramemethod, you want to check whether the distance between the centers of the circles is less than twice the radius. If true, then you have a collision.