[SOLVED] quick 1.1 shake animation
-
Hi,
Could someone show me how to do shake animation?
It is used when user type in wrong password, the text will move left and right, shake head.I used this code, but it is from 0 to 20, and jumps back to 0 to 20 again.
@NumberAnimation on x {
id: animationShake
loops: 5
from: 0
to: 20
}@Thanks
-
Hi,
I guess you will need to reverse from and to values when the animation stops and then again start the animation.
-
Could you show me how to do it ?
Thanks
-
Something like this
@
Rectangle {
x: 50
...
NumberAnimation on x{
id: anim
running: true
to: 60
duration: 100
onStopped: {
if(anim.to===60) { anim.from=60; anim.to=50; } else { anim.from=50; anim.to=60 }
start()
}
}
}
@ -
Thanks, but qml 1 doesn't have onStopped,
also, it runs forever here. -
Hmm. onCompleted should work instead.
Ofcourse it will, you can just include a counter and check it in onCompleted to stop the animation. -
Hmm, maybe this "here":http://qt-project.org/doc/qt-4.8/qml-sequentialanimation.html
-
+1 @dasRicardo. Forgot the simplest way :)
-
So please add [SOLVED] to your thread title.
-
Thanks for your help!
And it is working
[quote author="dasRicardo" date="1416903679"]Hmm, maybe this "here":http://qt-project.org/doc/qt-4.8/qml-sequentialanimation.html[/quote]