diff options
author | mae <qt-info@nokia.com> | 2010-09-09 12:57:54 (GMT) |
---|---|---|
committer | mae <qt-info@nokia.com> | 2010-09-09 12:59:00 (GMT) |
commit | a51c4ec60618ba575cb20e94bb019306074f432e (patch) | |
tree | a2b645e9b1ea2efca37ccc2b406ffbd7d5276018 /demos/declarative/snake/snake.qml | |
parent | 48b5fa29f5da3c241bc64520bd56ccd5713c4586 (diff) | |
download | Qt-a51c4ec60618ba575cb20e94bb019306074f432e.zip Qt-a51c4ec60618ba575cb20e94bb019306074f432e.tar.gz Qt-a51c4ec60618ba575cb20e94bb019306074f432e.tar.bz2 |
State handling cleanup
The game could end up in funky states when
restarting while the startup animation was
running. Also some smaller fixes for rotation.
Diffstat (limited to 'demos/declarative/snake/snake.qml')
-rw-r--r-- | demos/declarative/snake/snake.qml | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml index 12ad71c..df6e3ab 100644 --- a/demos/declarative/snake/snake.qml +++ b/demos/declarative/snake/snake.qml @@ -86,7 +86,7 @@ Rectangle { onTriggered: { Logic.moveSkull() } } Timer { - id: startNewGameTimer; + id: startNewGameTimer; interval: 700; onTriggered: { Logic.startNewGame(); } } @@ -94,11 +94,11 @@ Rectangle { Timer { id: startHeartbeatTimer; interval: 1000 ; - onTriggered: { state = "running"; heartbeat.running = true; } + onTriggered: { state = "running"; heartbeat.running = true;} } - Image { + Image { id: title source: "content/pics/snake.jpg" @@ -106,16 +106,29 @@ Rectangle { anchors.fill: parent anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - Behavior on opacity { NumberAnimation { duration: 500 } } - - Text { - color: "white" - font.pointSize: 24 - horizontalAlignment: Text.AlignHCenter - text: "Last Score:\t" + lastScore + "\nHighscore:\t" + highScores.topScore; - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - anchors.bottomMargin: gridSize + + Column { + spacing: 140 + anchors.verticalCenter: parent.verticalCenter; + anchors.left: parent.left; + anchors.right: parent.right; + + Text { + color: "white" + font.pointSize: 48 + font.italic: true; + font.bold: true; + text: "Snake" + anchors.horizontalCenter: parent.horizontalCenter; + } + + Text { + color: "white" + font.pointSize: 24 + anchors.horizontalCenter: parent.horizontalCenter; + //horizontalAlignment: Text.AlignHCenter + text: "Last Score:\t" + lastScore + "\nHighscore:\t" + highScores.topScore; + } } } @@ -145,7 +158,7 @@ Rectangle { MouseArea { anchors.fill: parent onPressed: { - if (!head || !heartbeat.running) { + if (screen.state == "") { Logic.startNewGame(); return; } @@ -236,7 +249,12 @@ Rectangle { from: "*" to: "starting" NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 } - + NumberAnimation { property: "opacity"; duration: 200 } + }, + Transition { + to: "starting" + NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 } + NumberAnimation { property: "opacity"; duration: 200 } } ] |