I want to pause my animation on button click:
-
I am using following code i want to pause and resume button on this animation:
@
Rectangle {
id: ball
Image {
id: img
source: "images/ring1.png"
}
// Add a property for the target y coordinate
property variant direction : "right"x: -100; width: 0; height: 0; z: 1 //color: "Lime" // Move the ball to the right and back to the left repeatedly SequentialAnimation on x { id:xani PauseAnimation { duration: 200 } running: false; loops: Animation.Infinite NumberAnimation { from:0;to: bubbleLevel.width - 40; duration: 3000 } ScriptAction { script: { } }} Behavior on y {id:yani; SpringAnimation{ id:sab; velocity: 150; } } Component.onCompleted: {y = bubbleLevel.height-100;} // start the ball motion onYChanged: { if (y <= 80) { y = bubbleLevel.height - 100; } if (y >= bubbleLevel.height - 130) { y = 0; } } }
@
-
Thanks mlong it stop moving on x-axis but not on y-axis ,if i put as sab.pause(); for stop and sab.resume(); to move again but its not working. On click event my image is moving on top or on the bottom of the screen, but not paused plz tell me why it is moving on yaxis.
-
it not pause my animation ,my (id:img) image moving on the bottom or top. i also want to resume animation where i paused.
-
I think xani.running = false is equal to xani.stop() Try with xani.paused property.
@
onClicked: {
xani.paused = !xani.paused
sab.paused = !sab.paused
}
@ -
not working task_struct :(
-
May be I don't understaned you well, but this works:
@
import QtQuick 1.0Rectangle {
id: bubbleLevelwidth: 400 height: 400 Rectangle { id: animItem width: 50 height: 50 color: "black" SequentialAnimation on x { id: xani loops: Animation.Infinite NumberAnimation { from: 10; to: 200 duration: 3000 } NumberAnimation { from: 200; to: 10 duration: 3000 } } } Rectangle { id: button width: 50 height: 30 color: "red" anchors.right: parent.right anchors.rightMargin: 5 anchors.bottom: parent.bottom anchors.bottomMargin: 5 Text { text: "click" } MouseArea { anchors.fill: parent onClicked: { xani.paused = !xani.paused } } }
}
@Is that what you're trying to achieve?
-
thanks , kindly add y component ,SpringAnimation, becuase m also want spring animation as a bouncing ball that spring animation not pausing.In the code below bubbleLevel is a background image having width, height as mobile's resolution (480*854).
@
Behavior on y {id:yani; SpringAnimation{ id:sab; velocity: 150; }
}
Component.onCompleted: {y = bubbleLevel.height-100;} // start the ball motion
onYChanged: {
if (y <= 80) {
y = bubbleLevel.height - 100;
}
if (y >= bubbleLevel.height - 130) {
y = 0;
}
}
@ -
Hello,
I've tried with Behavior animation and I receive this message:
@
QML SpringAnimation: setPaused() cannot be used on non-root animation nodes.
@I've also tried with @yani.animation.paused = !yani.animation.paused@ but result is the same.
It seems that there is another animation that contains animations declared in Behavior but it is not accessible. :( -
yes i don't know why yani.paused or sab.paused is not working :(