Reputation: 635
I am creating a game using libgdx for android. On my highscore screen when the user clicks the textfield to enter their name the onscreen keyboard appears and just covers the textfield so the user can not see what they are typing. To counter this I am trying to zoom my camera in to the textfield but when I use the zoom feature nothing happens and I don't understand why. Can anyone please point me in the right direction. Thanks. Below I am trying to zoom in when the textfield is clicked.
textscore.addListener(new ClickListener(){
public void clicked(InputEvent e, float x, float y) {
camera.zoom =2; //zoom in
textscore.getOnscreenKeyboard();
stage.setKeyboardFocus(textscore);
}
});
//in show
camera = new OrthographicCamera(Gdx.graphics.getWidth(),
Gdx.graphics.getHeight());
camera.setToOrtho(false, W,H);
stage.addActor(textscore);
textscore.setVisible(true);
textscore.addListener(new ClickListener(){
public void clicked(InputEvent e, float x, float y) {
System.out.println("focused");
camera.zoom -= 2;
//textscore.getOnscreenKeyboard();
//stage.setKeyboardFocus(textscore);
}
});
In render
camera.update();
Upvotes: 1
Views: 748
Reputation: 13571
first thing is better use
camera.zoom += 2; //zooming out
camera.zoom -= 2; //zooming in
secondly you've probably forgotten about
camera.update();
after setting its new zoom
Upvotes: 4