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 – animating disk movements

Our animation will consist of three parts, so it will require a fair amount of code. Instead of putting all that code directly into the Scene component, let's put the animation into a separate component. Create a new file called DiskAnimation.qml and fill it with the following code:

import QtQuick 2.10SequentialAnimation {    id: rootAnimation    property variant target: null    property vector3d rod1Pos    property vector3d rod2Pos    property int startY    property int finalY    property int maxY: 12    Vector3dAnimation {        target: rootAnimation.target        property: "pos"        to: Qt.vector3d(rod1Pos.x, maxY, rod1Pos.z)        duration: 30 * (maxY - startY)    }    Vector3dAnimation {        target: rootAnimation.target        property: "pos" to: Qt.vector3d(rod2Pos.x, ...

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