-
Notifications
You must be signed in to change notification settings - Fork 2
/
BounceBall.qml
78 lines (69 loc) · 1.86 KB
/
BounceBall.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
import QtQuick 1.1
Rectangle {
width: 240
height: 320
// color:"black"
property bool isDown: false
Rectangle {
id:circle
width: parent.width/3
height: width
radius: width
color: "#9f205b"
border.color: "yellow"
border.width: 1
smooth: true
// anchors.horizontalCenter: parent.horizontalCenter
// SequentialAnimation {
//// ParallelAnimation {
// id: bounce
// PropertyAnimation {
// property: y
// duration: 3000;
// to: 240
// easing.type: Easing.OutBounce;
// }
// PropertyAnimation {
// property: x
// duration: 3000;
// to: 160
// easing.type: Easing.OutBounce;
// }
// }
Behavior on y {
PropertyAnimation{
duration: 3000;
easing.type: Easing.OutBounce
}
}
Behavior on x {
PropertyAnimation {
duration: 3000;
easing.type: Easing.OutBounce
}
}
}
Button {
anchors.centerIn: parent
color: "green"
opacity: 0.5
MouseArea {
anchors.fill: parent
onClicked: {
console.log("clicked!");
// For Behavior
if(!isDown) { circle.y = 240; circle.x = 160; isDown= true}
else { circle.y = 0; circle.x = 0; isDown=false}
//// For SequentialAnimation
// bounce.start();
}
onPressed: {
parent.color = "black"
}
onReleased: {
parent.color = "green"
}
}
}
}