是否有可能在libgdx中歪曲演员

时间:2015-03-11 14:07:28

标签: java libgdx

是否可以在libgdx中歪曲/剪切演员(图像)?

我发现sprite可能存在偏差,如discussed here

演员怎么样?

1 个答案:

答案 0 :(得分:2)

这对我有用:

class SkewActor extends Actor {
    private TextureRegion tex;
    private Affine2 affine = new Affine2();

    public SkewActor(TextureRegion textureRegion) {
        this.tex = textureRegion;
    }

    @Override
    public void draw(Batch batch, float parentAlpha) {
        Color color = getColor();
        batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);

        affine.setToTranslation(getX(), getY());
        affine.shear(0.5f, 0);  // <- modify skew here
        batch.draw(tex,getWidth(), getHeight(), affine);

    }
}