I'm making a game for android in libgdx and I have been working on implementing a viewport. I have a libgdx touchpad as an actor on the stage and as soon as I apply the FitViewport to the stage, the touchpad knob does not resize correctly and fills the screen while all of the other elements resize properly. How do I get the touchpad knob to resize along with the other elements?
Here is my code:
private Touchpad touchpad;
private Touchpad.TouchpadStyle touchpadStyle;
private Skin touchpadSkin;
private Drawable touchBackground;
private Drawable touchKnob;
public PlayState(GameStateManager gsm) {
super(gsm);
touchpadSkin = new Skin();
//Set background image
touchpadSkin.add("touchBackground", new Texture("joystick_base.png"));
//Set knob image
touchpadSkin.add("touchKnob", new Texture("joystick_64.png"));
//Create TouchPad Style
touchpadStyle = new Touchpad.TouchpadStyle();
//Create Drawable's from TouchPad skin
touchBackground = touchpadSkin.getDrawable("touchBackground");
touchKnob = touchpadSkin.getDrawable("touchKnob");
touchpadStyle.background = touchBackground;
touchpadStyle.knob = touchKnob;
//Create new TouchPad with the created style
touchpad = new Touchpad(10, touchpadStyle);
//setBounds(x,y,width,height)
touchpad.setBounds(0.5f,0.5f,WORLD_WIDTH/7,WORLD_HEIGHT/5);
stage = new Stage(new FitViewport(WORLD_WIDTH,WORLD_HEIGHT));
stage.addActor(touchpad);
Gdx.input.setInputProcessor(stage);
protected void render(SpriteBatch sb) {
touchpad.draw(sb, 1);
}