Libgdx 舞台的 ProjectionMatrix?

Libgdx ProjectionMatrix for stage?

嘿,我对 ProjectionMatrix 有疑问。我在与标签相同的 x 坐标处绘制了一个矩形,但它们不在同一位置。舞台上有类似 ProjectionMatrix 的东西吗?

@Override
public void create() {
    batch = new SpriteBatch();
    stage = new Stage();
    shapeRenderer = new ShapeRenderer();
    camera = new OrthographicCamera();
    camera.setToOrtho(false, 480, 800);

    //create label
    generator = new FreeTypeFontGenerator(Gdx.files.internal("arial-black.ttf"));
    parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
    parameter.size = 50;
    parameter.color = Color.BLACK;
    font = generator.generateFont(parameter);
    labelStyle = new Label.LabelStyle();
    labelStyle.font = font;
    label = new Label("text", labelStyle);
    label.setPosition(240, 400);
    stage.addActor(label);
}

@Override
public void render() {
    delta = Gdx.graphics.getDeltaTime();
    Gdx.gl.glClearColor(255, 255, 255, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // tell the camera to update its matrices.
    camera.update();

    // tell the SpriteBatch to render in the
    // coordinate system specified by the camera.
    batch.setProjectionMatrix(camera.combined);
    shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix());

    stage.act(delta);
    stage.draw();

    shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    shapeRenderer.setColor(Color.BLACK);
    shapeRenderer.rect(label.getX(), 0, 50, 50);
    shapeRenderer.end();
  }

对视口使用舞台构造函数:

/** Creates a stage with the specified viewport. The stage will use its own {@link Batch} which will be disposed when the stage
 * is disposed. */
public Stage (Viewport viewport) {
    this(viewport, new SpriteBatch());
    ownsBatch = true;
}

Viewport viewport = new FitViewport(800, 480, camera);
Stage stage = new Stage(viewport);