O'Reilly logo

LibGDX Game Development By Example by James Cook

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Game reuse

Right before we dive into looking at tile maps and creating a wonderful world in which Pete will live, we need to set up our project.

Once you have created the project using the LibGDX setup tool—you should be good at that by now—we will need to create a GameScreen class as before, extending the ScreenAdapter class.

Remember, we will need the following objects in our GameScreen class:

  • ShapeRenderer
  • Viewport
  • Camera
  • SpriteBatch

As this is a platformer, we are going to want a view that is more landscape than we have had before. So, we will have a world size of 640 x 480:

private static final float WORLD_WIDTH = 640;
private static final float WORLD_HEIGHT = 480;

Then, we will keep the core functionality for updating and rendering. So, hopefully, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required