use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class BitmapFontTest method create.
@Override
public void create() {
spriteBatch = new SpriteBatch();
// font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), false);
font = new BitmapFont(Gdx.files.internal("data/arial-32-pad.fnt"), false);
// font = new FreeTypeFontGenerator(Gdx.files.internal("data/arial.ttf")).generateFont(new FreeTypeFontParameter());
font.getData().markupEnabled = true;
font.getData().breakChars = new char[] { '-' };
multiPageFont = new BitmapFont(Gdx.files.internal("data/multipagefont.fnt"));
// Add user defined color
Colors.put("PERU", Color.valueOf("CD853F"));
renderer = new ShapeRenderer();
renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix());
stage = new Stage(new ScreenViewport());
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
BitmapFont labelFont = skin.get("default-font", BitmapFont.class);
labelFont.getData().markupEnabled = true;
// Notice that the last [] has been deliberately added to test the effect of excessive pop operations.
// They are silently ignored, as expected.
label = new Label("<<[BLUE]M[RED]u[YELLOW]l[GREEN]t[OLIVE]ic[]o[]l[]o[]r[]*[MAROON]Label[][] [Unknown Color]>>", skin);
label.setPosition(100, 200);
stage.addActor(label);
Window window = new Window("[RED]Multicolor[GREEN] Title", skin);
window.setPosition(400, 300);
window.pack();
stage.addActor(window);
layout = new GlyphLayout();
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch in project libgdx by libgdx.
the class AlphaTest method create.
@Override
public void create() {
Pixmap pixmap = new Pixmap(256, 256, Format.RGBA8888);
pixmap.setColor(1, 0, 0, 1);
pixmap.fill();
texture = new Texture(pixmap, false);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
batch = new SpriteBatch();
pixmap.dispose();
}
use of com.badlogic.gdx.graphics.g2d.SpriteBatch 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.SpriteBatch 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.SpriteBatch 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();
}
Aggregations