How to set the size of cladding elements

I have a table that should have a checkerboard background. For this, I use ink embroidered:

TiledDrawable boardBg;
boardBg = new TiledDrawable(menuSkin.getTiledDrawable("boardBg"));
boardTable.setBackground(boardBg);

Then each tile has a size that can be done with defualt, for example 64px. What do I need to do so that each tile is larger? I tried

boardBg.setMinWidth(500);
boardBg.setMinHeight(500);

but it has no effect.

+4
source share
1 answer

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 );
    }
}
0

Source: https://habr.com/ru/post/1525942/


All Articles