为什么这些点不会显示交叉点

时间:2016-04-06 11:54:02

标签: java libgdx graphics2d

我无法让这些点相交。这是从相关函数中的Gdx日志中打印出来的。

W and L :  p1 [3616.0427:82.479935] p2 [3616.0427:90.479935] l1 [3616.0:64.0] l2 [3616.0:80.0]
W and L :  p1 [3616.0427:82.479935] p2 [3616.0427:90.479935] l1 [3616.0:80.0] l2 [3616.0:96.0]
W and L :  p1 [3616.0427:82.479935] p2 [3616.0427:90.479935] l1 [3616.0:96.0] l2 [3616.0:112.0]
W and L :  p1 [3616.0427:82.479935] p2 [3616.0427:90.479935] l1 [3616.0:112.0] l2 [3616.0:128.0]
W and L :  p1 [3616.0427:82.479935] p2 [3616.0427:90.479935] l1 [3616.0:128.0] l2 [3616.0:144.0]

我正在使用Intersector类:

for (Ladder l : ladders) {
        float x = worm.getCollisionRectangle().x;
        float y = worm.getCollisionRectangle().y;
        float lx = l.getBodyRectangle().x;
        float ly = l.getBodyRectangle().y;
        Vector2 p1 = new Vector2(x,y);
        Vector2 p2 = new Vector2(x, y + 8);
        Vector2 l1 = new Vector2(lx, ly);
        Vector2 l2 = new Vector2(lx, ly + 16);
        Gdx.app.log("W and L ", " p1 "  + p1 + " p2 " + p2 + " l1 " + l1 + " l2 " + l2);
        if (Intersector.intersectSegments(p1, p2, l1, l2 , null)) {
            WormUserData userData = worm.getUserData();
            Gdx.app.log("W and L", " inside loop");
            userData.setContact(true);
        }

0 个答案:

没有答案