我的libgdx
游戏有激光,我想知道光束是否击中了目标。
我在功能上遇到了一些麻烦(总是正确),所以我做了一个非常简单的测试,但我仍然正确!
我错过了什么?
为什么此函数返回true?
if(Intersector.intersectLinePolygon(new Vector2(100, 100), new Vector2(200, 100), new Polygon(new float[] {0, 0, 5, 0, 5, 5}))) {
System.out.println("true");
}
提前致谢!
当我也第一次使用Intersector时,就被这一点所吸引。
该intersectLinePolygon()
方法在无限延伸的直线上工作,而不仅仅是在您指定的两点之间。
使用intersectSegmentPolygon()
执行您想要的方法...
if(Intersector.intersectSegmentPolygon(new Vector2(100, 100), new Vector2(200, 100), new Polygon(new float[] {0, 0, 5, 0, 5, 5}))) {
System.out.println("true");
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句