是否可以在 libgdx 中倾斜演员

Is it possible to skew actor in libgdx

skew/shear演员(图片)可以libgdx吗?

我发现 sprite 可能会倾斜,因为 discussed here

演员呢?

这对我有用:

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);

    }
}