1 /******************************************************************************* 2 * Copyright 2011 See AUTHORS file. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 ******************************************************************************/ 16 17 package com.badlogic.gdx.tests; 18 19 import com.badlogic.gdx.Gdx; 20 import com.badlogic.gdx.graphics.GL20; 21 import com.badlogic.gdx.graphics.g2d.SpriteBatch; 22 import com.badlogic.gdx.scenes.scene2d.Actor; 23 import com.badlogic.gdx.scenes.scene2d.Stage; 24 import com.badlogic.gdx.scenes.scene2d.ui.Label; 25 import com.badlogic.gdx.scenes.scene2d.ui.Skin; 26 import com.badlogic.gdx.scenes.scene2d.ui.Table; 27 import com.badlogic.gdx.tests.utils.GdxTest; 28 29 public class LabelScaleTest extends GdxTest { 30 Skin skin; 31 Stage stage; 32 SpriteBatch batch; 33 Actor root; 34 35 @Override create()36 public void create () { 37 batch = new SpriteBatch(); 38 skin = new Skin(Gdx.files.internal("data/uiskin.json")); 39 stage = new Stage(); 40 Gdx.input.setInputProcessor(stage); 41 42 Table table = new Table(); 43 stage.addActor(table); 44 table.setPosition(200, 65); 45 46 Label label1 = new Label("This text is scaled 2x.", skin); 47 label1.setFontScale(2); 48 Label label2 = new Label( 49 "This text is scaled. This text is scaled. This text is scaled. This text is scaled. This text is scaled. ", skin); 50 label2.setWrap(true); 51 label2.setFontScale(0.75f, 0.75f); 52 53 table.debug(); 54 table.add(label1); 55 table.row(); 56 table.add(label2).fill(); 57 table.pack(); 58 } 59 60 @Override dispose()61 public void dispose () { 62 stage.dispose(); 63 skin.dispose(); 64 } 65 66 @Override render()67 public void render () { 68 Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1); 69 Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); 70 71 stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); 72 stage.draw(); 73 } 74 75 @Override resize(int width, int height)76 public void resize (int width, int height) { 77 stage.getViewport().update(width, height, true); 78 } 79 } 80