Pārlūkot izejas kodu

Introduce image count display

Change-Id: Ibef5d9d8afb0bc16ff4729b93032c0a5c6414546
Donald Carr 9 gadi atpakaļ
vecāks
revīzija
7abc1f5e9f
1 mainītis faili ar 24 papildinājumiem un 2 dzēšanām
  1. 24 2
      Gravity.qml

+ 24 - 2
Gravity.qml

@@ -14,10 +14,16 @@ Item {
 
     anchors.fill: parent
 
+    QtObject {
+        id: d
+        property double pace: settings.pace/60.0
+        property int itemCount: 0
+    }
+
     World {
         // Global world at odds with relative positions!
         id: commonWorld
-        timeStep: settings.pace/60.0
+        timeStep: d.pace
     }
 
     Component {
@@ -39,7 +45,7 @@ Item {
             World {
                 id: columnWorld
 
-                timeStep: settings.pace/60.0
+                timeStep: d.pace
                 Component.onCompleted: worldArray.push(columnWorld)
             }
 
@@ -61,9 +67,11 @@ Item {
                 repeat: true
                 interval: 1000*(settings.interval > 60 ? 60*(settings.interval-60) : settings.interval)*(Math.random()+1)
                 onTriggered: {
+                    d.itemCount++
                     pictureArray.push(pictureDelegate.createObject(column, { y: -2000 }))
                     if (pictureArray.length > settings.columnCount) {
                         pictureArray.shift().detonate()
+                        d.itemCount--
                     }
                 }
             }
@@ -134,6 +142,20 @@ Item {
         }
     }
 
+    Rectangle {
+        z: 1
+        color: "black"
+        anchors { right: parent.right; top: parent.top }
+        width: itemCountLabel.width
+        height: itemCountLabel.height
+        Text {
+            id: itemCountLabel
+            font.pixelSize: 100
+            text: d.itemCount
+            color: "white"
+        }
+    }
+
     Keys.onUpPressed: root.togglePause()
     Keys.onDownPressed: root.toggleChaos() //root.next()
 }