-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGui.qml
42 lines (38 loc) · 1.05 KB
/
Gui.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
import QtQuick 1.0
Rectangle {
id: topLevel
anchors.fill: parent
color: "grey"
x: 0
y: 0
Rectangle {
id: ball
height: 50
width: 50
color: "red"
radius: 100
}
Connections {
target: accelerometerReader
onXMovementChanged: {
if (ball.x != accelerometerReader.xMovement) {
var temp = ball.x + (accelerometerReader.xMovement)*(-1)
if (temp < 0)
temp = 0;
else if ((temp + ball.width) > topLevel.width)
temp = topLevel.width - ball.width
ball.x = temp
}
}
onYMovementChanged: {
if (ball.y != accelerometerReader.yMovement) {
var temp = ball.y + accelerometerReader.yMovement
if (temp < 0)
temp = 0;
else if ((temp + ball.height) > topLevel.height)
temp = topLevel.height - ball.height
ball.y = temp
}
}
}
}