summaryrefslogtreecommitdiffstats
path: root/demos/declarative
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2010-08-16 08:11:20 (GMT)
committermae <qt-info@nokia.com>2010-08-16 08:12:42 (GMT)
commitaf675cf96d4d13b066a669eae847ad56485927d0 (patch)
treefcc3cfdc6b27c03e8ccb5385a4c830f22e317611 /demos/declarative
parentb83c295650b3f28bc9da542acf4652f4ce2d168b (diff)
downloadQt-af675cf96d4d13b066a669eae847ad56485927d0.zip
Qt-af675cf96d4d13b066a669eae847ad56485927d0.tar.gz
Qt-af675cf96d4d13b066a669eae847ad56485927d0.tar.bz2
Fix game could not be restarted
Task-number: QT-3668
Diffstat (limited to 'demos/declarative')
-rw-r--r--demos/declarative/snake/content/snake.js5
-rw-r--r--demos/declarative/snake/snake.qml16
2 files changed, 5 insertions, 16 deletions
diff --git a/demos/declarative/snake/content/snake.js b/demos/declarative/snake/content/snake.js
index 0f0dbf7..fab7834 100644
--- a/demos/declarative/snake/content/snake.js
+++ b/demos/declarative/snake/content/snake.js
@@ -35,9 +35,12 @@ function startNewGame()
if (heartbeat.running) {
endGame();
startNewGameTimer.running = true;
+ state = "starting";
return;
}
+ state = "starting";
+
numRows = numRowsAvailable;
numColumns = numColumnsAvailable;
board = new Array(numRows * numColumns);
@@ -80,7 +83,6 @@ function startNewGame()
waitForCookie = 5;
score = 0;
startHeartbeatTimer.running = true;
- heartbeat.running = true;
}
function endGame()
@@ -94,6 +96,7 @@ function endGame()
}
lastScore = score;
highScores.saveScore(lastScore);
+ state = "";
}
function move() {
diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml
index b1344af..ed3bac9 100644
--- a/demos/declarative/snake/snake.qml
+++ b/demos/declarative/snake/snake.qml
@@ -94,6 +94,7 @@ Rectangle {
Timer {
id: startHeartbeatTimer;
interval: 1000 ;
+ onTriggered: { state = "running"; heartbeat.running = true; }
}
@@ -208,21 +209,6 @@ Rectangle {
Keys.onUpPressed: if (state == "starting" || direction != 2) Logic.scheduleDirection(0);
Keys.onDownPressed: if (state == "starting" || direction != 0) Logic.scheduleDirection(2);
- Connections {
- target: startHeartbeatTimer
- onRunningChanged: {
- if (startHeartbeatTimer.running)
- screen.state = "starting";
- else
- screen.state = "running"
- }
- }
- Connections {
- target: heartbeat
- onRunningChanged: if (!heartbeat.running) screen.state = "";
- }
-
-
states: [
State {
name: "starting"