自己指定顶点坐标,绘制图形,左上为00,右下为1
public class Test extends Group {
private float[] fx = new float[20];
private Image image;
public Test(){
image = new Image(new Texture("tou.png"));
addActor(image);
setSize(image.getWidth(),image.getHeight());
}
@Override
public void draw(Batch batch, float parentAlpha) {
float whitebits = Color.WHITE.toFloatBits();
fx[0] = getX();
fx[1] = getY();
fx[2] = whitebits;
fx[3] = 0F; // u v
fx[4] = 1F;
fx[5] = getX();
fx[6] = getY() + getHeight()/9;
fx[7] = whitebits;
fx[8] = 0F;
fx[9] = 0F;
fx[10] = getX() + getWidth();
fx[11] = getY() + getHeight();
fx[12] = whitebits;
fx[13] = 1F;
fx[14] = 0F;
fx[15] = getX() + getWidth();
fx[16] = getY();
fx[17] = whitebits;
fx[18] = 1F;
fx[19] = 1F;
batch.draw(((TextureRegionDrawable)(image.getDrawable())).getRegion().getTexture(), fx, 0, 20);
}
}
效果
image.png
网友评论