i needed help attaching circle1 Sprite to circle2 Sprite on collision onto the same point where they are getting collided, and both circles are moving with Action. Like this,
Attaching means, when circle1 and circle2 sprites get collided, i am removing circle1 Sprite from scene and creating new sprite at that same position of circle1.
I have implemented following code for collision .... float dx = circle1.x - circle2.x; float dy = circle1.y - circle2.y; float distance = Math.sqrt(dx * dx + dy * dy);
if (distance < circle1.radius + circle2.radius) { // collision detected // removing older sprite // creating of new sprite }
Its working perfectly when one circle sprite in motion and another is static.
But when both are in motion, at some points ( collision point like bottom-left/ up-right of circle2 ) its get attached little over circle2 sprite and it happens at random times so i couldn't able to detect the error.
I want to attach new Sprite at exact point where collision occurred like this,
Anybody have done it before..