We defined our collision behavior, but it is also necessary that we write a logic that defines our collision itself. So, we make a collision detection function:
public boolean collision(GameObj a, GameObj b) { if(Rect.intersects(a.getRectangle(), b.getRectangle())) { return true; } return false;}
Our collision function is now ready.