Android Games: Textos

De Aulas

Links relacionados: Jogos Digitais

Recursos

Classe MyGdxGame

 1package com.mygdx.game;
 2
 3import com.badlogic.gdx.ApplicationAdapter;
 4import com.badlogic.gdx.Gdx;
 5import com.badlogic.gdx.Input;
 6import com.badlogic.gdx.graphics.GL20;
 7import com.badlogic.gdx.graphics.g2d.BitmapFont;
 8import com.badlogic.gdx.graphics.g2d.SpriteBatch;
 9
10public class MyGdxGame implements ApplicationListener {
11	private SpriteBatch batch;
12	private BitmapFont font;
13	private int w, h;
14
15	@Override
16	public void create() {
17		w = Gdx.graphics.getWidth();
18		h = Gdx.graphics.getHeight();
19		batch = new SpriteBatch();
20		font = new BitmapFont(
21				Gdx.files.internal("verdana.fnt"),
22				Gdx.files.internal("verdana.png"), false);
23		font.setColor(1, 1, 1, 1);
24	}
25
26	@Override
27	public void render() {
28		Gdx.gl.glClearColor(0, 0, 0, 1);
29		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
30		batch.begin();
31		font.draw(batch, "Hello android game world!", 1, h + 1);
32		batch.end();
33	}
34
35	@Override
36	public void dispose() {
37		batch.dispose();
38		font.dispose();
39	}
40}