6
如何創建一個動畫,其中一個項目的尺寸擴大,然後縮小到原始大小(從頂部/鳥瞰圖中考慮「彈跳球」)。到目前爲止,我只找到了如何利用創建單向動畫「行爲上的x/y」通過修改parent.x和parent.y如何在QML中創建'放大,然後縮小'動畫?
例如...
Rectangle {
id: container;
width: 700
height: 700
function goForIt(parent) {
parent.x = (Math.floor(Math.random()*600));
parent.y = (Math.floor(Math.random()*600));
parent.width += 100;
parent.height += 100;
}
Image {
id: head;
source: "vlad.png";
height: 80;
width: 90;
MouseArea {
anchors.fill: parent
onClicked: goForIt(parent);
}
Behavior on x {
PropertyAnimation {
target: head;
properties: "x";
duration: 1000;
}
}
Behavior on y {
PropertyAnimation {
target: head;
properties: "y";
duration: 1000;
}
}
Behavior on height {
PropertyAnimation {
target: head;
properties: "height";
duration: 1000;
}
}
Behavior on width {
PropertyAnimation {
target: head;
properties: "width";
duration: 1000;
}
}
}
}