August 2015
Intermediate to advanced
280 pages
5h 31m
English
Before we start making the Snake game, we need to set up our textures for the snake and the game play area. So, let's remove the default code from our GameScreen class, leaving just our SpriteBatch batch's clear screen calls:
public class GameScreen extends ScreenAdapter {
private SpriteBatch batch;
@Override
public void show() {
batch = new SpriteBatch();
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
}Next, let's change the color that fills the screen from red to black. We can do this by updating the glClearColor method call to reference the r, g, b, a values of the black Color class:
Gdx.gl.glClearColor(Color.BLACK.r, Color.BLACK.g, Color.BLACK.b, ...