Hello, I'm trying to code a breakout scenario according to the Joy of Code videos on youtube. I am having trouble getting the ball to correctly detect when it hits the paddle. For some reason, the ball always acts as though the collision happens slightly above where the paddle appears on the screen, instead of colliding with the actual paddle image. If I move the paddle closer to the ball, the ball still detects the collision as occurring above the paddle instead of on it no matter what.
Here is the code I am currently using to detect paddle collision.
private void checkPaddle()
{
Actor paddle = getOneIntersectingObject(paddle.class);
if (paddle != null) {
deltaY = -deltaY;
int offset = getX() - paddle.getX();
deltaX = deltaX + (offset/10);
if (deltaX > 7) {
deltaX = 7;
}
if (deltaX < -7) {
deltaX = -7;
}
}
}
