I’ve managed to get two moving objects to detect whether they’ve touched or not, but currently it only works when the center of the sprites touch.
I tried adding the sprite width and height into the collision check, but it still doesn’t work.
This is what I have:
boolean collidingWith(Collidable other){
return x + w + movementSpeed> other.x &&
x - movementSpeed< other.x + other.w &&
y + h + movementSpeed> other.y &&
y - movementSpeed < other.y + other.h;
}
It also doesn’t work very consistently when both objects are moving