Search in sources :

Example 71 with BitmapFont

use of com.badlogic.gdx.graphics.g2d.BitmapFont in project libgdx by libgdx.

the class AnnotationTest method create.

@Override
public void create() {
    font = new BitmapFont();
    batch = new SpriteBatch();
    try {
        Annotation annotation = ClassReflection.getDeclaredAnnotation(AnnotatedClass.class, TestAnnotation.class);
        if (annotation != null) {
            TestAnnotation annotationInstance = annotation.getAnnotation(TestAnnotation.class);
            println("Class annotation:\n name=" + annotationInstance.name() + ",\n values=" + Arrays.toString(annotationInstance.values()) + ",\n enum=" + annotationInstance.someEnum().toString());
        } else {
            println("ERROR: Class annotation not found.");
        }
        Field field = ClassReflection.getDeclaredField(AnnotatedClass.class, "annotatedValue");
        if (field != null) {
            Annotation[] annotations = field.getDeclaredAnnotations();
            for (Annotation a : annotations) {
                if (a.getAnnotationType().equals(TestAnnotation.class)) {
                    TestAnnotation annotationInstance = a.getAnnotation(TestAnnotation.class);
                    println("Field annotation:\n name=" + annotationInstance.name() + ",\n values=" + Arrays.toString(annotationInstance.values()) + ",\n enum=" + annotationInstance.someEnum().toString());
                    break;
                }
            }
        } else {
            println("ERROR: Field 'annotatedValue' not found.");
        }
        Method method = ClassReflection.getDeclaredMethod(AnnotatedClass.class, "annotatedMethod");
        if (method != null) {
            Annotation[] annotations = method.getDeclaredAnnotations();
            for (Annotation a : annotations) {
                if (a.getAnnotationType().equals(TestAnnotation.class)) {
                    TestAnnotation annotationInstance = a.getAnnotation(TestAnnotation.class);
                    println("Method annotation:\n name=" + annotationInstance.name() + ",\n values=" + Arrays.toString(annotationInstance.values()) + ",\n enum=" + annotationInstance.someEnum().toString());
                    break;
                }
            }
        } else {
            println("ERROR: Method 'annotatedMethod' not found.");
        }
        println("Class annotations w/@Inherit:");
        Annotation[] annotations = ClassReflection.getAnnotations(InheritClassB.class);
        for (Annotation a : annotations) {
            println(" name=" + a.getAnnotationType().getSimpleName());
        }
        if (!ClassReflection.isAnnotationPresent(InheritClassB.class, TestInheritAnnotation.class)) {
            println("ERROR: Inherited class annotation not found.");
        }
    } catch (Exception e) {
        println("FAILED: " + e.getMessage());
        message += e.getClass();
    }
}
Also used : Field(com.badlogic.gdx.utils.reflect.Field) Method(com.badlogic.gdx.utils.reflect.Method) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Annotation(com.badlogic.gdx.utils.reflect.Annotation)

Example 72 with BitmapFont

use of com.badlogic.gdx.graphics.g2d.BitmapFont in project libgdx by libgdx.

the class AtlasIssueTest method create.

public void create() {
    batch = new SpriteBatch();
    batch.setProjectionMatrix(new Matrix4().setToOrtho2D(0, 0, 855, 480));
    atlas = new TextureAtlas(Gdx.files.internal("data/issue_pack"), Gdx.files.internal("data/"));
    sprite = atlas.createSprite("map");
    font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false);
    Gdx.gl.glClearColor(0, 1, 0, 1);
}
Also used : TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Matrix4(com.badlogic.gdx.math.Matrix4)

Example 73 with BitmapFont

use of com.badlogic.gdx.graphics.g2d.BitmapFont in project libgdx by libgdx.

the class NoncontinuousRenderingTest method create.

@Override
public void create() {
    batch = new SpriteBatch();
    texture = new Texture("data/badlogic.jpg");
    region = new TextureRegion(texture);
    stage = new Stage(new ScreenViewport(), batch);
    Gdx.input.setInputProcessor(stage);
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    skin.add("default", font = new BitmapFont(Gdx.files.internal("data/arial-32.fnt"), false));
    populateTable();
    Gdx.graphics.setContinuousRendering(false);
    Gdx.graphics.requestRendering();
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Stage(com.badlogic.gdx.scenes.scene2d.Stage) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) ScreenViewport(com.badlogic.gdx.utils.viewport.ScreenViewport) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

Example 74 with BitmapFont

use of com.badlogic.gdx.graphics.g2d.BitmapFont in project libgdx by libgdx.

the class ParallaxTest method create.

@Override
public void create() {
    Texture texture = new Texture(Gdx.files.internal("data/layers.png"));
    layers = new TextureRegion[3];
    layers[0] = new TextureRegion(texture, 0, 0, 542, 363);
    layers[1] = new TextureRegion(texture, 0, 363, 1024, 149);
    layers[2] = new TextureRegion(texture, 547, 0, 224, 51);
    camera = new ParallaxCamera(480, 320);
    controller = new OrthoCamController(camera);
    Gdx.input.setInputProcessor(controller);
    batch = new SpriteBatch();
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) OrthoCamController(com.badlogic.gdx.tests.utils.OrthoCamController) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 75 with BitmapFont

use of com.badlogic.gdx.graphics.g2d.BitmapFont in project libgdx by libgdx.

the class LabelTest method render.

@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();
    float x = 40, y = 40;
    BitmapFont font = skin.getFont("default-font");
    batch.begin();
    font.draw(batch, "The quick brown fox jumped over the lazy cow.", x, y);
    batch.end();
    drawLine(x, y - font.getDescent(), x + 1000, y - font.getDescent());
    drawLine(x, y - font.getCapHeight() + font.getDescent(), x + 1000, y - font.getCapHeight() + font.getDescent());
}
Also used : BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Aggregations

BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)104 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)64 Texture (com.badlogic.gdx.graphics.Texture)31 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)21 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)18 Stage (com.badlogic.gdx.scenes.scene2d.Stage)16 OrthoCamController (com.badlogic.gdx.tests.utils.OrthoCamController)13 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)12 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)11 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)10 Drawable (com.badlogic.gdx.scenes.scene2d.utils.Drawable)10 AssetManager (com.badlogic.gdx.assets.AssetManager)9 Color (com.badlogic.gdx.graphics.Color)8 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)8 InputAdapter (com.badlogic.gdx.InputAdapter)7 Actor (com.badlogic.gdx.scenes.scene2d.Actor)7 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)7 FileHandle (com.badlogic.gdx.files.FileHandle)6 Pixmap (com.badlogic.gdx.graphics.Pixmap)6 GlyphLayout (com.badlogic.gdx.graphics.g2d.GlyphLayout)6