Book Image

LibGDX Game Development By Example

By : James Cook
Book Image

LibGDX Game Development By Example

By: James Cook

Overview of this book

Table of Contents (18 chapters)
LibGDX Game Development By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Setting up LibGDX with Box2D


Right, we need a LibGDX project that has Box2D support. The question is, how do we go ahead and create that? Well, the eagle-eyed among you will have noticed that Box2D was a selectable option in the project setup application we used previously and in fact it will have been already preselected!

The preceding partial screenshot of the setup application shows what you see when you rerun the application.

Set up the application like we have done so previously, but with Box2D ticked, and then we are good to go!

Code reuse

Next, before we dive into Box2D, let's reuse some code from our previous projects.

Firstly, we should update our NuttyGame class so it extends the Game class. This isn't something new, just look at our previous games!

Next, we can bring across our LoadingScreen class and create a simple GameScreen class. Don't worry about screen sizes for now, we will come to them later.

Hopefully, your game class will look like this:

public class NuttyGame extends Game...