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, ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.