TiledDrawable . , TiledDrawable . , 0,1, ( ) . . , , , , , setScale, , . ScaledTiledDrawable :
ScaledTiledDrawable scaledTiledDrawable = new ScaledTiledDrawable( new TextureRegion( texture ) );
scaledTiledDrawable.getScale().set( 0.5f, 0.5f );
:
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 );
}
}