【问题标题】:Libgdx blending two masks?Libgdx 混合两个面具?
【发布时间】:2015-04-14 08:51:24
【问题描述】:

屏幕分为两个部分,我有两组纹理。

我想裁剪每个纹理组以适合屏幕的每个部分。 如何使用混合(蒙版)实现这一点?

这是我用 MSPaint 制作的一张图片来描述这种情况:

【问题讨论】:

  • 如果您知道哪个纹理属于哪一侧,则在绘制每个纹理之前设置适当的视口。
  • 图片做得很好!

标签: java opengl libgdx color-blending


【解决方案1】:

我不知道如何使用混合蒙版来做到这一点,但你可以通过剪刀测试来做到这一点。

private Rectangle leftSide;
private Rectangle rightSide;

public void resize (int width, int height) {
    //...

    leftSide = new Rectangle(0, 0, width/2, height);
    rightSide = new Rectangle(width/2, 0, width/2, height);
}

public void render() {

    //...

    spriteBatch.begin();
    //draw background

    spriteBatch.flush();
    ScissorStack.pushScissors(leftSide);
    //draw left side stuff that is cropped
    spriteBatch.flush();
    ScissorStack.popScissors();
    ScissorStack.pushScissors(rightSide);
    //draw right side stuff that is cropped
    spriteBatch.flush();
    ScissorStack.popScissors();
    //draw any other stuff that is not cropped on top of everything else
    spriteBatch.end();
}

【讨论】:

  • 谢谢!有用!直到现在我才知道 ScissorStacks。
猜你喜欢
  • 1970-01-01
  • 2014-08-25
  • 1970-01-01
  • 2015-07-25
  • 2018-10-31
  • 2019-10-26
  • 1970-01-01
  • 1970-01-01
  • 2023-03-17
相关资源
最近更新 更多