Kuesa Car-Scene QML Example
import QtQuick 2.11
Rectangle {
id: wind
color: "black"
property bool animating: visible
Image {
id: bg
source: "bg.png"
anchors.fill: parent
opacity: 0.5
}
function randomDuration() {
return Math.random() * 6000 + 4000
}
Image {
id: t1
source: "t1.png"
height: parent.height / 4
fillMode: Image.PreserveAspectFit
anchors.right: parent.right
anchors.rightMargin: -width / 20
rotation: 180
NumberAnimation on y {
duration: randomDuration()
easing.type: Easing.InOutCubic
to: Math.random() * wind.height - t1.height * .2
onStopped: {
duration = randomDuration()
to = Math.random() * wind.height - t1.height * .2
running = Qt.binding(function() { return animating })
}
running: animating
}
}
Image {
id: t2
source: "t2.png"
height: parent.height / 5
fillMode: Image.PreserveAspectFit
y: -height / 15
NumberAnimation on x {
duration: randomDuration()
easing.type: Easing.InOutCubic
to: Math.random() * wind.width * 0.8 - t2.width
onStopped: {
duration = randomDuration()
to = Math.random() * wind.width * 0.8 - t2.width
running = Qt.binding(function() { return animating })
}
running: animating
}
}
Image {
id: t3
source: "t3.png"
width: parent.width / 9
fillMode: Image.PreserveAspectFit
anchors.bottom: parent.bottom
NumberAnimation on x {
duration: randomDuration()
easing.type: Easing.InOutCubic
to: Math.random() * wind.width * 0.9 - t3.width
onStopped: {
duration = randomDuration()
to = Math.random() * wind.width * 0.9 - t3.width
running = Qt.binding(function() { return animating })
}
running: animating
}
}
}