本文整理汇总了Java中com.badlogic.gdx.math.Intersector.intersectSegments方法的典型用法代码示例。如果您正苦于以下问题:Java Intersector.intersectSegments方法的具体用法?Java Intersector.intersectSegments怎么用?Java Intersector.intersectSegments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.math.Intersector
的用法示例。
在下文中一共展示了Intersector.intersectSegments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkCollision
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
@Override
public boolean checkCollision(Vector2 p1, Vector2 p2) {
// Intersect left edge
if (Intersector.intersectSegments(p1.x, p1.y, p2.x, p2.y, mXPos, mYPos, mXPos, mYPos + mHeight, null))
return true;
// Intersect right edge
if (Intersector.intersectSegments(p1.x, p1.y, p2.x, p2.y, mXPos + mWidth, mYPos, mXPos + mWidth,
mYPos + mHeight, null))
return true;
// Intersect top edge
if (Intersector.intersectSegments(p1.x, p1.y, p2.x, p2.y, mXPos, mYPos + mHeight, mXPos + mWidth,
mYPos + mHeight, null))
return true;
// Intersect bottom edge
if (Intersector.intersectSegments(p1.x, p1.y, p2.x, p2.y, mXPos, mYPos, mXPos + mWidth, mYPos, null))
return true;
return false;
}
示例2: collideWithHull
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
/**
* Check if a line from a to b intersects with the convext hull.
* If so, the point of intersection is stored in the intersect vector.
* @param a point one
* @param b point two
* @param intersect point of intersection
* @return true if intersect. Point of intersection stored in intersect
*/
public boolean collideWithHull(Vector2 a, Vector2 b, Vector2 intersect) {
//for each line segment between two vertices
float[] verticies = hullPoly.getTransformedVertices();
for (int v = 0; v < verticies.length - 2; v += 2) {
float xA = verticies[v];
float yA = verticies[v + 1];
float xB = verticies[v + 2];
float yB = verticies[v + 3];
// convex hull line between A and B
Vector2 edgeA = new Vector2(xA, yA);
Vector2 edgeB = new Vector2(xB, yB);
if (Intersector.intersectSegments(edgeA, edgeB, a, b, intersect)) {
//the two lines intersect. point of intersection is set in variable intersect
return true;
}
}
return false;
}
示例3: drawIntersectingLines
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
private void drawIntersectingLines(DelaunayCell cell, Vector2 mid, Vector2 edgeA, Vector2 edgeB) {
Vector2 intersect = new Vector2();
if (Intersector.intersectSegments(edgeA, edgeB, cell.circumcenter, mid, intersect)) {
shape.setColor(Color.GREEN);
shape.line(mid, intersect);
shape.circle(intersect.x, intersect.y, 3);
}
}
示例4: collisionAtPoints
import com.badlogic.gdx.math.Intersector; //导入方法依赖的package包/类
private static boolean collisionAtPoints(float f1, float f2, float f3, float f4
, float f5, float f6, float f7, float f8) {
return Intersector.intersectSegments(f1, f2, f3, f4, f5, f6, f7, f8, null);
}