I have a libgdx game I am working, and in this game, when you hit the "Help" screen, my Help_Manager class uses my "Room's" stage object to draw a label. The room's camera is 27 wide, and 18 tall. The stage uses the same camera, and set's it's viewport to the same WIDTH, and HEIGHT.
If I were to add a text button to the stage with bounds(4,4,1,1), the button draws correctly, but when I add a Label with bounds(0,0,16,4) the labels "S" alone takes up half the screen (shown above)(it's supposed to say "Swipe finger from ship to \"Fling\" ship."). No matter what I set the bounds width and height to, the label is still the same size. Changing the scale doesn't have an effect either. Changing the font-scale(of the label, not the font) does have an effect, but for some reason the text is all messed up:
Heres bits and peices of code: Room.java:
Stage stage = new Stage();
camera = new OrthographicCamera(WIDTH,HEIGHT);
camera.position.set(WIDTH/2,HEIGHT/2,0);
camera.update();
stage.setCamera(camera);
stage.setViewport(WIDTH, HEIGHT, false);
public void resize(int width, int height){
ppux = width/WIDTH;
ppuy = height/HEIGHT;
stage.setViewport(Room.WIDTH,Room.HEIGHT,false);
}
public void render(float delta){
stage.act(delta);
stage.draw();
}
Help_Manager.java
BitmapFont font = new BitmapFont();
LabelStyle style = new LabelStyle();
Label text;
style.font = font;
text = new Label(instructions[0],style);
text.setText(instructions[stage]);
text.setBounds(0,0,16,4);
//text.setFontScale(0.1f);
room.stage.addActor(text);
So how do I get my label to cooperate? Thanks in advance for any help!
Well, I discovered that fonts by default use integers for positions. When using a small camera size and stage viewport, means that the letters need to be placed more acurately, and so I had to change the font.setUseIntegerPosistions(false); I also discovered, that when you set the bonds for a Label, this simply defines the space that can be used, but it is still being filled with the same font, and size of text. Your putting the same stuff in a bigger/smaller box. (This explains why the text moves up as you increase the height of your Label, your raising the top bound, and the text starts at the top). To actually change the size of the font youse text.setFontScale();