如何使用给定Rectangle
在Actor
周围绘制Texture
? Rectangle
应与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();
问题在于移动Rectangle
后Actor
不适合。我认为这与糟糕的Coordinate Transformation
。
我想做这样的事情:
Matix4 m = actor.computeTransform();
shapeRenderer.setTransformMatrix(m);
但 computeTransform()在Group
(Actor
)中可用,但在Actor
本身不可用。