在下面我取回顶点的ArrayList代码(我已经调试和他们实际上有),然后尝试使他们这是在渲染方法托管于该窝循环排列。 出于某种原因,如果这是嵌套在ShapeRenderer不能连接所有的线? 谁能告诉我,我做错了什么? 没有什么是被绘制到屏幕上; 我没有得到任何错误。
shapeRenderer.setProjectionMatrix(camera.combined);
shapeRenderer.begin(ShapeType.Line);
for(int i = 0;i<tmpBodies.size;i++)
{
if(tmpBodies.get(i).getType().equals(BodyType.DynamicBody) &&
!tmpBodies.get(i).equals(car.getChassis()) &&
!tmpBodies.get(i).equals(car.rightWheel)&&
!tmpBodies.get(i).equals(car.leftWheel)&&
!tmpBodies.get(i).equals(terrain)) // tmpBodies.get(i).getFixtureList().get(0).getShape().equals(Type.Chain)
{
ChainShape tempShape = new ChainShape();
ArrayList<Vector2> bodyPoints = new ArrayList<Vector2>();
tempShape = (ChainShape)tmpBodies.get(i).getFixtureList()
.get(0).getShape();
for(int q=0; q<tempShape.getVertexCount(); q++)
{
Vector2 linePoints = new Vector2();
tempShape.getVertex(q, linePoints);
Vector2 newLinePoints = tmpBodies.get(i).getWorldPoint(linePoints);
bodyPoints.add(newLinePoints);
}
for(int z=0; z<tempShape.getVertexCount()-1; z++)
{
shapeRenderer.setColor(1, 1, 0, 1);
shapeRenderer.line(bodyPoints.get(z).x,
bodyPoints.get(z).y,
bodyPoints.get(z+1).x,
bodyPoints.get(z+1).y);
}
}
}