How to make my collision check with Intersect between rectangles to work?

流过昼夜 提交于 2019-12-04 22:54:56
java.awt.Rectangle[x=393,y=788,width=14,height=14] 
java.awt.Rectangle[x=350,y=350,width=100,height=10]

As you can see the second rectangle's y/height 350/10 but the first's y=788

Obviously they have no intersection one is above another

UPDATE One more thing

public static Rectangle getBounds()
{
    return new Rectangle(x, y, radius*2, radius*2);                     
}

If x and y are the ball's center the code should be

public static Rectangle getBounds()
{
    return new Rectangle(x-radius, y-radius, radius*2, radius*2);                     
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!