demos/declarative/snake/snake.qml
changeset 37 758a864f9613
parent 33 3e2da88830cd
--- a/demos/declarative/snake/snake.qml	Fri Sep 17 08:34:18 2010 +0300
+++ b/demos/declarative/snake/snake.qml	Mon Oct 04 01:19:32 2010 +0300
@@ -94,6 +94,7 @@
     Timer {
         id: startHeartbeatTimer;
         interval: 1000 ;
+        onTriggered: { state = "running"; heartbeat.running = true; }
     }
 
 
@@ -105,7 +106,6 @@
             anchors.fill: parent
             anchors.horizontalCenter: parent.horizontalCenter
             anchors.verticalCenter: parent.verticalCenter
-            Behavior on opacity { NumberAnimation { duration: 500 } }
 
             Text {
                 color: "white"
@@ -193,6 +193,12 @@
             anchors.verticalCenter: parent.verticalCenter
         }
 
+        Content.Button {
+            text: "Quit"
+            anchors { left: btnA.right; leftMargin: 3; verticalCenter: parent.verticalCenter }
+            onClicked: Qt.quit();
+        }
+
         Text {
             color: activePalette.text
             text: "Score: " + score; font.bold: true
@@ -211,14 +217,12 @@
     states: [
         State {
             name: "starting"
-            when: startHeartbeatTimer.running
             PropertyChanges {target: progressIndicator; width: 200}
             PropertyChanges {target: title; opacity: 0}
             PropertyChanges {target: progressBar; opacity: 1}
         },
         State {
             name: "running"
-            when: (heartbeat.running && !startHeartbeatTimer.running)
             PropertyChanges {target: progressIndicator; width: 200}
             PropertyChanges {target: title; opacity: 0}
             PropertyChanges {target: skull; row: 0; column: 0; }
@@ -231,7 +235,10 @@
             from: "*"
             to: "starting"
             NumberAnimation { target: progressIndicator; property: "width"; duration: 1000 }
-
+            NumberAnimation { target: title; property: "opacity"; duration: 500 }
+        },
+        Transition {
+            NumberAnimation { target: title; property: "opacity"; duration: 500 }
         }
     ]