我一直在写一个游戏引擎,我的演员类有问题。我想确定一个矩形(上图)和矩形的一边的碰撞。我为他们写了两种方法。Java游戏碰撞检测,(侧面碰撞)与矩形
public boolean isLeftCollision(Actor actor) {
boolean bool = false;
Rectangle LeftBounds = new Rectangle(x, y, x-velocity, image.getHeight(null));
bool = LeftBounds.intersects(actor.getBounds());
return bool;
}
public boolean isRightCollision(Actor actor) {
boolean bool = false;
Rectangle RightBounds = new Rectangle(x+image.getWidth(null), y, image.getWidth(null)+velocity, image.getHeight(null));
bool = RightBounds.intersects(actor.getBounds());
return bool;
}
这里速度是下一步的运动。
但他们都给我错误(即错误的判断)。我该如何在演员课上解决这个问题。
添加错误日志 – 2012-01-15 00:06:08
@stas如何添加错误日志 – 2012-01-15 00:13:15
lol。运行该程序并复制并粘贴该错误。 – 2012-01-15 00:15:57