Below is the code where i create a box moving along a line
I need help to have more independent boxes (3 or more) to move in the same line.
import QtQuick 2.0
Rectangle {
id: window
width: 320
height: 480
Canvas {
id: canvas
anchors.fill: parent
antialiasing: true
onPaint: {
var context = canvas.getContext("2d")
context.clearRect(0, 0, width, height)
context.strokeStyle = "black"
context.path = pathAnim.path
context.stroke()
}
}
SequentialAnimation {
running: true
loops: -1
PauseAnimation { duration: 1000 }
//! [0]
PathAnimation {
id: pathAnim
duration: 2000
easing.type: Easing.InQuad
target: box
orientation: PathAnimation.RightFirst
anchorPoint: Qt.point(box.width/2, box.height/2)
path: Path {
startX: 0; startY: 100
PathLine{x:600 ; y:100 }
onChanged: canvas.requestPaint()
}
}
//! [0]
}
Rectangle {
id: box
x: 25; y: 25
width: 50; height: 50
border.width: 1
antialiasing: true
Text {
anchors.centerIn: parent
text: "Box"
}
}
}
↧