演员周围的libgdx矩形

时间:2014-02-09 14:11:20

标签: java libgdx bounding-box rect

如何使用给定RectangleActor周围绘制TextureRectangle应与Actor一起缩放,移动和旋转。 目前的实施:

shapeRenderer.begin(ShapeType.Line); 
shapeRenderer.setColor(Color.RED); 
Vector2 _BL = localToStageCoordinates(new Vector2(getX(), getY()));
Vector2 _BR = localToStageCoordinates(new Vector2(getX() + getWidth(), getY()));
Vector2 _TL = localToStageCoordinates(new Vector2(getX(), getY() + getHeight()));
Vector2 _TR = localToStageCoordinates(new Vector2(getX() + getWidth(), getY() + getHeight()));
float xmin = MyMathUtils.min(_BL.x, _BR.x, _TL.x, _TR.x);
float ymin = MyMathUtils.min(_BL.y, _BR.y, _TL.y, _TR.y);
float xmax = MyMathUtils.max(_BL.x, _BR.x, _TL.x, _TR.x);
float ymax = MyMathUtils.max(_BL.y, _BR.y, _TL.y, _TR.y);
shapeRenderer.rect(xmin, ymin, xmax-xmin, ymax-ymin);
shapeRenderer.setColor(Color.BLUE);
shapeRenderer.circle(_BL.x, _BL.y, 2);
shapeRenderer.circle(_BR.x, _BR.y, 2);
shapeRenderer.circle(_TL.x, _TL.y, 2);
shapeRenderer.circle(_TR.x, _TR.y, 2);
shapeRenderer.end();

问题在于移动RectangleActor不适合。我认为这与糟糕的Coordinate Transformation

有关

我想做这样的事情:

Matix4 m = actor.computeTransform();
shapeRenderer.setTransformMatrix(m);

computeTransform()GroupActor)中可用,但在Actor本身不可用。

0 个答案:

没有答案