Time for action – constructing the Tower of Hanoi scene

Our next task will be to create a foundation and three rods for our puzzle. We will take advantage of QML's modular system and split our code into multiple components. First, let's leave camera and lighting settings in the main.qml and put our actual scene content to a new Scene component. In order to do that, put the text cursor onto the Entity declaration of the cube, press Alt + Enter and select Move Component into Separate File. Input Scene as the component name and confirm the operation. Qt Creator will create a new Scene.qml file and add it to the project's resources. The main.qml now contains just an instantiation of our scene component:

Entity {    //...    Scene { }}

The actual properties ...

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.