**This is an old revision of the document!**

How to make a platform game : player animations

This tutorial will explain you how to add different animations and how to use events to change the animations when the state of the player is changing.

Click here to read the previous part if you have not done it already.

Add animations

For now, the player is always displaying the same image: using the events, we're going to change its animation according to what he is doing.

Before doing this, we must add the appropriate animations to the Player object.

Jumping animation

Open the editor of the Player object, make sure you're on the Properties tab, then click on the + button on the bottom of the window to add an animation. Finally, click on the + button of the new animation and choose p1_jump as the image to add:

Animations can be given name, it's an easy way to differentiate between them and use them in the events. It's as simple as clicking on “Optional animation name” and typing the name you want.

Enter “Idle” and “Jumping” as names for our two animations:

Running animation

We need another animation which the one displayed when the character is running on a platform. Add another animation like we did, and, when adding images, select the 5 images p1walk03.png, p1walk04.png, … and p1_walk07.png. Also set the name of the animation to Running:

These images will be displayed so as to create the animation. We need to tweak a bit some options: first click on Don't loop to switch this option to Loop. The timer is displaying the time in seconds between each image. Enter 0.05 instead of 1 so that the animation is faster:

Our object is now ready!

Use events to change animations

Now, we need to change the animation displayed by the object according to what the player do. We're going to use the events, which are used to describe the rules of the game and how objects are animated, moved and respond to player inputs. It's a kind of visual programming that can be learn very quickly and is accessible to all.

Open the events editor of the scene by cliking on the tab called New Scene (events).

For now, the events editor is empty: