本文整理匯總了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);
}