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();
}
}
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);
}
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();
}
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);
}
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());
}
Aggregations