Commit b22bbe26 authored by Exc404's avatar Exc404

Анимация движения карточки игры

parent 38ca2d7c
...@@ -25,31 +25,42 @@ Rectangle { ...@@ -25,31 +25,42 @@ Rectangle {
function startAnimation(){ function startAnimation(){
// gameRect.anchors.leftMargin= 8
// gameRect.anchors.topMargin= 70
// gameRect.anchors.left= gameRect.parent.left
// gameRect.anchors.top= gameRect.parent.top
startPos.x = startX
startPos.y = startY
gameRect.anchors.left = startPos.left
gameRect.anchors.top = startPos.top
container.state = "completed"
}
states:[
State {
name: "finish"
AnchorChanges {
target: gameRect;
anchors.left: startPos.left
anchors.top: startPos.top
} }
states: State { },
State {
name: "completed" name: "completed"
AnchorChanges { AnchorChanges {
target: gameRect; target: gameRect;
//anchors.leftMargin: 8 anchors.left: finishPos.left
//anchors.topMargin: 70 anchors.top: finishPos.top
anchors.left: gameRect.parent.left
anchors.top: gameRect.parent.top
} }
} }
]
transitions: Transition { transitions: Transition {
// smoothly reanchor myRect and move into new position // smoothly reanchor myRect and move into new position
AnchorAnimation { duration: 1000 } AnchorAnimation { duration: 300 }
} }
Component.onCompleted: container.state = "completed"
onVisibleChanged: function(){ onVisibleChanged: function(){
...@@ -67,13 +78,24 @@ Rectangle { ...@@ -67,13 +78,24 @@ Rectangle {
// // Start pos
Item { Item {
id: startPos id: startPos
x: startX x: startX
y: startY y: startY
} }
// finish pos
Item {
id: finishPos
anchors.left: gameRect.parent.left
anchors.top: gameRect.parent.top
anchors.leftMargin: 8
anchors.topMargin: 70
}
Rectangle { Rectangle {
id: rectangle id: rectangle
...@@ -96,6 +118,11 @@ Rectangle { ...@@ -96,6 +118,11 @@ Rectangle {
imageUrl: "../images/back.svg" imageUrl: "../images/back.svg"
onClicked: function(){ onClicked: function(){
window.scene = S.homeScene; window.scene = S.homeScene;
//gameRect.anchors.leftMargin= 0
//gameRect.anchors.topMargin= 0
container.state = "finish"
} }
} }
...@@ -195,8 +222,6 @@ Rectangle { ...@@ -195,8 +222,6 @@ Rectangle {
anchors.left: startPos.left
anchors.top: startPos.top
Image { Image {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment