是否可以在 libgdx 中扭曲演员 [英] Is it possible to skew actor in libgdx

查看:29
本文介绍了是否可以在 libgdx 中扭曲演员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possible to skew/shear actor (image) in libgdx?

我发现精灵可能会出现倾斜,如 在此处讨论

I have found that skew is possible for sprites, as 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);

    }
}

这篇关于是否可以在 libgdx 中扭曲演员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆