是否可以在 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);
}
}
相关文章