summaryrefslogtreecommitdiffstats
path: root/demos/declarative/snake/snake.qml
diff options
context:
space:
mode:
Diffstat (limited to 'demos/declarative/snake/snake.qml')
-rw-r--r--demos/declarative/snake/snake.qml12
1 files changed, 11 insertions, 1 deletions
diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml
index 5b69217..6eaa976 100644
--- a/demos/declarative/snake/snake.qml
+++ b/demos/declarative/snake/snake.qml
@@ -47,6 +47,7 @@ Rectangle {
id: screen;
SystemPalette { id: activePalette }
color: activePalette.window
+ property bool activeGame: false
property int gridSize : 34
property int margin: 4
@@ -75,6 +76,7 @@ Rectangle {
Timer {
id: heartbeat;
interval: heartbeatInterval;
+ running: activeGame && runtime.isActiveWindow
repeat: true
onTriggered: { Logic.move() }
}
@@ -94,9 +96,17 @@ Rectangle {
Timer {
id: startHeartbeatTimer;
interval: 1000 ;
- onTriggered: { state = "running"; heartbeat.running = true; }
+ onTriggered: { state = "running"; activeGame = true; }
}
+ Image{
+ id: pauseDialog
+ z: 1
+ source: "content/pics/pause.png"
+ anchors.centerIn: parent;
+ //opacity is deliberately not animated
+ opacity: gameActive && !runtime.isActiveWindow
+ }
Image {
Image {