Pretty much I want to check an entire area for an object. Here is my attempted code:
But it only really ends up checking when x = (positive) this.getImage().getWidth() because it loops until that.
Here is the game and full code for testing.
public boolean isOnGround()
{
for (int x = -this.getImage().getWidth() / 2; x <= this.getImage().getWidth(); x++)
{
Actor obstacle = getOneObjectAtOffset(x, this.getImage().getHeight() / 2, Obstacle.class);
if (obstacle != null)
{
return true;
}
else
{
return false;
}
}
return isOnGround();
}
