Introducing Pete
So far we have created a level using Tiled, and we have implemented tile maps in LibGDX so that we can see that level. The next step is to introduce our characters into this world and have them interact with the surroundings.
The preceding image shows Pete, our lovely squirrel! He has four different poses, two for walking and one each for jumping up and down.
Adding our character
Before we add our textures to Pete, let's go through the process of creating our character in code and have them interact with the world, then we can implement the animations.
Let's create class for Pete, I have called it Pete
and in that class we are going create the core components for controlling Pete, and also add a basic collision rectangle. This class is also going to be very similar to the Flappee
class from the previous chapters.
Here is how the Pete
class should look:
public class Pete { private static final float MAX_X_SPEED = 2; private static final float MAX_Y_SPEED = 2; public static...