1 Attachment(s)
Rotation Animation doesn't proceed after following animation restart
Hi All,
I am a new in QML area but with years of experience in C++ but lately I hit an issue with Rotation Animation after I restarted animation
of rotating and bouncing ball.
After app is started the ball correctly moves, rotates and bounces. But after I click the ball to restart the animation the ball moves, bounces like before but does not rotate. Is it anything missed in the code below. The code is taken from online book Qt5 cadaques. Is anything missed or is it not found yet bug in Qt QML?
import QtQuick 2.2
import QtQuick.Window 2.1
Window {
visible: true
width: root.width
height: root.height
Image {
id: root
width: 480
height: 350
property int duration: 3000
Rectangle {
id: sky
width: parent.width
height: 200
gradient: Gradient {
GradientStop { position: 0.0; color: "#0080FF"}
GradientStop { position: 1.0; color: "#66CCFF"}
}
}
Rectangle {
id: ground
anchors.top: sky.bottom
anchors.bottom: root.bottom
width: parent.width
gradient: Gradient {
GradientStop { position: 0.0; color: "#00FF00"}
GradientStop { position: 1.0; color: "#00803F"}
}
}
}
Image {
id: ball
x: 20; y: 240
rotation: 0
source: "assets/Soccer_ball.png"
MouseArea {
anchors.fill: parent
onClicked: {
ball.x = 20; ball.y = 240
anim.restart()
}
}
}
ParallelAnimation {
id: anim
SequentialAnimation {
NumberAnimation {
target : ball
properties: "y"
to: 20
duration: root.duration * 0.4
easing.type: Easing.OutCirc
}
NumberAnimation {
target: ball
properties: "y"
to: 240
duration: root.duration * 0.6
easing.type: Easing.OutBounce
}
}
NumberAnimation {
target: ball
properties: "x"
to: 400
duration: root.duration
}
RotationAnimation {
target: ball
properties: "rotation"
to: 720
duration: root.duration * 1.1
}
}
}
Re: Rotation Animation doesn't proceed after following animation restart
I'd say because the rotation value is not reset on mouse click.
Cheers,
_
Re: Rotation Animation doesn't proceed after following animation restart
Yes exactly. I found the solution before entered the thread again. Sometimes a man is blind.