3
我在过渡中制作了动画。所以如果状态发生变化,那么过渡就会发生。这是我制作的连续动画。QML:SequencialAnimation的运行属性设置为false,但仍在运行
SequentialAnimation{
PropertyAnimation{
properties: "width"
duration: 300
}
PropertyAnimation{
properties: "x"
duration: 500
}
Component.onCompleted: {
var idx = Math.ceil(Math.random()*2);
if(idx===0){
anim0.running = true
anim1.running = false
}
else {
anim1.running = true
anim0.running = false
}
console.log("haha");
}
}
SequentialAnimation{
id: anim0
running: false
NumberAnimation{
running: anim0.running
properties: "x"
to: 300
duration: 500
}
Component.onCompleted: console.log("anim0");
}
SequentialAnimation{
id: anim1
running: false
NumberAnimation{
running: anim1.running
properties: "x"
to: -300
duration: 500
}
Component.onCompleted: console.log("anim1");
}
忽略Component.onCompleted信号中的JavaScript。 SequencialAnimation id为:anim1和anim0继续运行,虽然我已经设置运行属性设置为false ...
海.. thx为您的帮助..但是,如何做到这一点?我必须在连续动画中调用它吗?或使用信号?我对qml很新。 –
嗯,这取决于你想做什么......在这种情况下,你将'running'属性设置为true? –
我使用ScriptAction来调用animationId.start(),它工作.. thx bro .. –