Time for action – making the sun rise and set

Let's add vertical movement (animation of the y property) to our sun by adding a sequence of animations to the QML document. As our new animations are going to be running in parallel to the horizontal animation, we could enclose animations for both directions within a single ParallelAnimation group. It would work, but in our opinion this would unnecessarily clutter the document. Another way of specifying parallel animations is to declare them as separate hierarchies of elements, making each animation independent of the other, and that is what we are going to do here.

Open our document from the last exercise and right under the previous animation, place the following code:

SequentialAnimation { NumberAnimation ...

Get Game Programming Using Qt 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.