Reputation: 703
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
Upvotes: 1
Views: 774
Reputation: 36602
In your onFrame
method, 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.
Upvotes: 2