Tag: 相交

如何通过矩形之间的相交来检查碰撞是否有效?

编辑:这里是完整的代码: https : //dl.dropboxusercontent.com/u/65678182/assignment1.rar任何可能的帮助非常感谢! 我正在尝试制作突破游戏的副本,但我在检查两个物体(球和桨)是否相交时遇到问题。 我现在有这种碰撞检测方法: public static void handleCollisions() { System.out.println(ball.getBounds()); // just to check that they System.out.println(paddle.getBounds()); //are there and moving correct if (ball.getBounds().intersects(paddle.getBounds())) { System.out.println(“collision”); } } 我很确定getBounds的工作原理应该是因为我从println获得这些输出:java.awt.Rectangle [x = 393,y = 788,width = 14,height = 14] java.awt.Rectangle [x = 350,Y = 350,宽度= 100,高度= 10] getBounds code: public static Rectangle getBounds() { […]