0
我知道如何将矩形切出图像。但我想剪出一个圈或一个自定义的面具。libGDX从图像中切出区域(自定义,不是矩形)
在Google Play的一些游戏(黑暗重生)中有这个标志。 这是如何完成的?
class MyActor extends Actor {
Rectangle scissors = new Rectangle();
Rectangle clipBounds = new Rectangle(0,0,100,100);
Sprite sprite = new Sprite(new Texture(Gdx.files.internal("images/test2.png")));
public MyActor() {
sprite.getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
sprite.setScale(2f);
setBounds(sprite.getX(), sprite.getY(), sprite.getWidth(), sprite.getHeight());
setTouchable(Touchable.enabled);
}
@Override
public void draw(Batch batch, float parentAlpha) {
ScissorStack.calculateScissors(camera, batch.getTransformMatrix(), clipBounds, scissors);
ScissorStack.pushScissors(scissors);
sprite.draw(batch, parentAlpha);
}
}
感谢awser。我会尝试。 –