Is it possible to skew actor in libgdx

ε祈祈猫儿з 提交于 2020-01-02 15:25:24

问题


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

I have found that skew is possible for sprites, as discussed here

What about an actor?


回答1:


this worked for me:

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

    }
}


来源:https://stackoverflow.com/questions/28988823/is-it-possible-to-skew-actor-in-libgdx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!