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 – Adding jumping with sprite transitions

Let's replace the AnimatedSprite class with the SpriteSequence class in the Bejamin the Elephant animation, adding a sprite to be played during the jumping phase.

Open the Player.qml file and replace the AnimatedSprite object with the following code:

SpriteSequence {    id: sprite    width: 80    height: 52    interpolate: false    anchors.bottom: parent.bottom    anchors.horizontalCenter: parent.horizontalCenter    running: true    Sprite {        name: "still"        source: "images/sprite.png"        frameCount: 1        frameWidth: 80; frameHeight: 52        frameDuration: 100        to: { "still": 1, "walking": 0, "jumping": 0 }    }    Sprite {        name: "walking"        source: "images/sprite.png"        frameX: 560; frameY: 0        frameCount: 7 frameWidth: 80; frameHeight: ...

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