TiledDrawable 클래스는 확장을 지원하지 않습니다. TiledDrawable을 확장하고 크기를 조정할 수있는 클래스를 만들었습니다. 0.1 이상으로 스케일을 축소하고 싶지 않은 것이 바람직합니다 (텍스처의 크기에 따라 다름). 축소 할 때주의해서 사용하십시오. 내가 스케일을 0으로 설정했을 때 계정에 대한 정보가 없으므로 상황이 발생할 때 오류가 발생하는 setScale 메소드를 작성할 수 있습니다. 이 같은 ScaledTiledDrawable을 사용
public class ScaledTiledDrawable extends TiledDrawable {
private Vector2 scale = new Vector2();
private Affine2 transform = new Affine2();
private Matrix4 matrix = new Matrix4();
private Matrix4 oldMatrix = new Matrix4();
public ScaledTiledDrawable() {
super();
}
public ScaledTiledDrawable(TextureRegion region) {
super(region);
}
public ScaledTiledDrawable(TextureRegionDrawable drawable){
super(drawable);
}
public Vector2 getScale() {
return scale;
}
@Override
public void draw(Batch batch, float x, float y, float width, float height) {
oldMatrix.set(batch.getTransformMatrix());
matrix.set(transform.setToTrnScl(x, y, scale.x, scale.y));
batch.setTransformMatrix(matrix);
super.draw(batch, 0, 0, width/scale.x, height/scale.y);
batch.setTransformMatrix(oldMatrix);
}
}
: 여기
ScaledTiledDrawable scaledTiledDrawable = new ScaledTiledDrawable(new TextureRegion(texture));
scaledTiledDrawable.getScale().set(0.5f, 0.5f);
는 클래스입니다