/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.tests.utils.GdxTest; public class LabelScaleTest extends GdxTest { Skin skin; Stage stage; SpriteBatch batch; Actor root; @Override public void create () { batch = new SpriteBatch(); skin = new Skin(Gdx.files.internal("data/uiskin.json")); stage = new Stage(); Gdx.input.setInputProcessor(stage); Table table = new Table(); stage.addActor(table); table.setPosition(200, 65); Label label1 = new Label("This text is scaled 2x.", skin); label1.setFontScale(2); Label label2 = new Label( "This text is scaled. This text is scaled. This text is scaled. This text is scaled. This text is scaled. ", skin); label2.setWrap(true); label2.setFontScale(0.75f, 0.75f); table.debug(); table.add(label1); table.row(); table.add(label2).fill(); table.pack(); } @Override public void dispose () { stage.dispose(); skin.dispose(); } @Override public void render () { Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); } @Override public void resize (int width, int height) { stage.getViewport().update(width, height, true); } }