Assuming your image is a square, no. You could use the AABB method I guess but if its 2 squares you can do it like this:
1 2 3 4 5 6 7 8
| public boolean collides(Rect a, Rect b) { if(a.x < b.x + b.width) return true; if(a.y < b.y + b.height) return true; if(a.x + a.width > b.x) return true; if(a.y + a.height > b.y) return true;
return false; } |
However, if your characters are circles, then yes. You can use the distance formula and check if the distance returned is less than the radius of both circles added together. Then there is a collision.