August 2015
Intermediate to advanced
280 pages
5h 31m
English
We now have our assets. Let's add them to the assets folder in our project and start adding them into the game.
First up, let's add the background (bg.png). This is a relatively simple affair; like we did earlier, we create a Texture object that represents the background, then draw it. So, in the GameScreen class, add the following code:
private Texture background;
public void show() {
/** Code omitted for brevity **/
background = new Texture(Gdx.files.internal("bg.png"));
}
private void draw() {
batch.setProjectionMatrix(camera.projection);
batch.setTransformMatrix(camera.view);
batch.begin();
batch.draw(background, 0, 0);
drawScore();
batch.end();
}Let's run it and see how it looks:
Excellent, we are almost there! ...
Read now
Unlock full access