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 { target: sun property: "y" from: root.height+sunVisual.height to: root.height-270 duration: dayLength/3 } PauseAnimation { duration: dayLength/3 } NumberAnimation { target: sun property...