Reputation: 63
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?
Upvotes: 3
Views: 1179
Reputation: 4081
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);
}
}
Upvotes: 4