summaryrefslogtreecommitdiffstats
path: root/demos/declarative
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2010-06-08 10:00:17 (GMT)
committermae <qt-info@nokia.com>2010-06-08 10:00:17 (GMT)
commite5567b2e0513f5a03987f78df2d565c0e6c6a951 (patch)
treebfd19f1520fa6cf256a84f9c8a1e7df19a5ab1da /demos/declarative
parent9623b49fd3055ede03569e6e9a46a4237f6e119f (diff)
downloadQt-e5567b2e0513f5a03987f78df2d565c0e6c6a951.zip
Qt-e5567b2e0513f5a03987f78df2d565c0e6c6a951.tar.gz
Qt-e5567b2e0513f5a03987f78df2d565c0e6c6a951.tar.bz2
Fix snake demo
Code degeneration lead to three bugs: 1. progress bar worked only the first time 2. restart was broken 3. highscore model was not persistent Reviewed-by: Trust me
Diffstat (limited to 'demos/declarative')
-rw-r--r--demos/declarative/snake/content/HighScoreModel.qml2
-rw-r--r--demos/declarative/snake/content/snake.js1
-rw-r--r--demos/declarative/snake/snake.qml12
3 files changed, 12 insertions, 3 deletions
diff --git a/demos/declarative/snake/content/HighScoreModel.qml b/demos/declarative/snake/content/HighScoreModel.qml
index 99799c8..42482f8 100644
--- a/demos/declarative/snake/content/HighScoreModel.qml
+++ b/demos/declarative/snake/content/HighScoreModel.qml
@@ -106,7 +106,7 @@ ListModel {
}
if (rs.rows.length > maxScores)
tx.executeSql("DELETE FROM HighScores WHERE game=? AND score <= ?",
- [rs.rows.item(maxScores).score]);
+ [game, rs.rows.item(maxScores).score]);
}
}
)
diff --git a/demos/declarative/snake/content/snake.js b/demos/declarative/snake/content/snake.js
index 6f78b33..4d05e33 100644
--- a/demos/declarative/snake/content/snake.js
+++ b/demos/declarative/snake/content/snake.js
@@ -37,6 +37,7 @@ function startNewGame()
startNewGameTimer.running = true;
return;
}
+
numRows = numRowsAvailable;
numColumns = numColumnsAvailable;
board = new Array(numRows * numColumns);
diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml
index 565e92c..46114f5 100644
--- a/demos/declarative/snake/snake.qml
+++ b/demos/declarative/snake/snake.qml
@@ -86,7 +86,7 @@ Rectangle {
onTriggered: { Logic.moveSkull() }
}
Timer {
-
+ id: startNewGameTimer;
interval: 700;
onTriggered: { Logic.startNewGame(); }
}
@@ -177,7 +177,6 @@ Rectangle {
id: progressIndicator
color: "#221edd";
width: 0;
- Behavior on width { NumberAnimation { duration: startHeartbeatTimer.running ? 1000 : 0}}
height: 30;
}
}
@@ -227,4 +226,13 @@ Rectangle {
}
]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "starting"
+ NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 }
+
+ }
+ ]
+
}