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

Adding a collectable


We almost have a platforming game! Admittedly, it doesn't do much—yet! But hey, let's change that. One of the main components of a platformer is having something for the player to collect. Considering Pete is a squirrel, I guess it is only right that he collects acorns.

To add our collectable to the game, we are going to need to do a couple of things. Firstly, we need to find a way for us to place the collectables in the game in an easy-to-do manner , next, have them successfully load that information into LibGDX, and then, finally, have the interaction between Pete and the acorn.

Our acorn will look as follows:

So, what can we use to place the acorn(s) in the level? Well, luckily, we have been using a certain mapping tool in this chapter that we can use to do this. Yup, that's right! Tiled has the capability to help us.

In Tiled, our first task is to add our acorn image as a tileset so that we can use it. Simply select New Tileset from the Map menu, navigate to the acorn...