diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2019-11-28 14:30:34 +0100 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2019-11-29 10:34:41 +0100 |
commit | c2f6a4cf63e18503f360f8237e119d663853c8db (patch) | |
tree | 2e4033c2154f9b96a9e4b4cfcba5149d4a4ff556 /examples/quick/touchinteraction/multipointtouch | |
parent | 6efdefda285063d5742709482834666eaed11037 (diff) |
examples/touchinteraction/multipointtouch: Fix broken score display
Fixes the broken score display in "Bearwhack".
Change-Id: I43581947f71e4c6dd3cca43068f6d220a058cc46
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'examples/quick/touchinteraction/multipointtouch')
-rw-r--r-- | examples/quick/touchinteraction/multipointtouch/bearwhack.qml | 12 | ||||
-rw-r--r-- | examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml | 9 |
2 files changed, 13 insertions, 8 deletions
diff --git a/examples/quick/touchinteraction/multipointtouch/bearwhack.qml b/examples/quick/touchinteraction/multipointtouch/bearwhack.qml index 49bd0b9db8..90c1a66891 100644 --- a/examples/quick/touchinteraction/multipointtouch/bearwhack.qml +++ b/examples/quick/touchinteraction/multipointtouch/bearwhack.qml @@ -87,7 +87,7 @@ Item { running: !startScreen.visible } - property int score: 0 + property int score: particleSystem.score Text { anchors.right: parent.right @@ -96,11 +96,13 @@ Item { color: "white" function padded(num) { var ret = num.toString(); - while (ret.length < 6) - ret = "0" + ret; - return ret; + + if (ret >= 0) + return ret.padStart(6, "0"); + else + return "-" + ret.substr(1).padStart(6, "0"); } - text: "Score: " + padded(score) + text: "Score: " + padded(root.score) } MultiPointTouchArea { anchors.fill: parent diff --git a/examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml b/examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml index 3db9eaf1e5..8da5949a1b 100644 --- a/examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml +++ b/examples/quick/touchinteraction/multipointtouch/content/BearWhackParticleSystem.qml @@ -52,6 +52,9 @@ import QtQuick.Particles 2.0 ParticleSystem { id: particleSystem + + property int score + function explode(x,y) { fireEmitter.burst(100,x,y); } @@ -116,13 +119,13 @@ ParticleSystem { once: true y: parent.height - 32 groups: "bears" - onAffectParticles: { + onAffectParticles: function(particles) { for (var i=0;i<particles.length; i++) { if (particles[i].animationIndex != 0) { - score++; + particleSystem.score++; bloodEmitter.burst(100, particles[i].x, particles[i].y); } else { - score--; + particleSystem.score--; heartEmitter.burst(100, particles[i].x, particles[i].y); } particles[i].update = 1.0; |