O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

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

Time for action – Implementing simple character animation

Let's try to make the player character animated in a simple way. In the materials that come with this book, you will find a number of images with different walking phases for Benjamin the Elephant. You can use them, or you can draw or download some other images to be used in place of those provided by us.

Put all images in one directory (for example, images) and rename them so that they follow a pattern that contains the base animation name followed by a frame number, for example, walking_01, walking_02, walking_03, and so on.

Next, open the Player.qml document and replace the image element showing elephant.png with the following code:

Image {    id: elephantImage property int currentFrame: ...

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