Author: davedes (posted 2012-10-14 22:15:46, viewed 174 times)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
| package atmos;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class Main implements ApplicationListener {
public static void main(String[] args) {
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
cfg.title = "atmos";
cfg.useGL20 = false;
cfg.width = 480;
cfg.height = 320;
new LwjglApplication(new Main(), cfg);
}
BitmapFont font;
SpriteBatch batch;
OrthographicCamera camera;
@Override
public void create() {
font = new BitmapFont();
batch = new SpriteBatch();
camera = new OrthographicCamera();
}
@Override
public void resize(int width, int height) {
camera.setToOrtho(false, width, height);
batch.setProjectionMatrix(camera.combined);
}
@Override
public void render() {
Gdx.gl10.glClear(GL10.GL_COLOR_BUFFER_BIT);
batch.begin();
font.setColor(Color.WHITE);
font.draw(batch, "This is a test", 50, 50);
font.setColor(Color.RED);
font.draw(batch, "This is another test", 50, 150);
batch.end();
}
@Override
public void pause() {
}
@Override
public void resume() {
}
@Override
public void dispose() {
font.dispose();
batch.dispose();
}
} |
Special syntax:
- To highlight a line (yellow background), prefix it with '@@'
- To indicate that a line should be removed (red background), prefix it with '-'
- To indicate that a line should be added (green background), prefix it with '+'
- To post multiple snippets, seperate them by '~~~~'
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|