Fixed samegame tutorial part 4 to reflect Quick2 state
authorOliver Wolff <oliver.wolff@digia.com>
Thu, 13 Dec 2012 15:19:46 +0000 (16:19 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 14 Dec 2012 06:41:59 +0000 (07:41 +0100)
Change-Id: I61a3d63bc0268256ff6497339a6d97719a59860f
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
examples/quick/tutorials/samegame/samegame4/content/BoomBlock.qml
examples/quick/tutorials/samegame/samegame4/content/samegame.js
src/quick/doc/src/advtutorial.qdoc

index 335f4ae..5b9928e 100644 (file)
@@ -39,7 +39,7 @@
 ****************************************************************************/
 
 import QtQuick 2.0
-import Qt.labs.particles 1.0
+import QtQuick.Particles 2.0
 
 Item {
     id: block
@@ -81,23 +81,30 @@ Item {
     //![2]
 
     //![3]
-    Particles {
-        id: particles
-
-        width: 1; height: 1
+    ParticleSystem {
+        id: sys
         anchors.centerIn: parent
+        ImageParticle {
+            // ![0]
+            source: {
+                if (type == 0)
+                    return "../../shared/pics/redStar.png";
+                else if (type == 1)
+                    return "../../shared/pics/blueStar.png";
+                else
+                    return "../../shared/pics/greenStar.png";
+            }
+            rotationVelocityVariation: 360
+            // ![0]
+        }
 
-        emissionRate: 0
-        lifeSpan: 700; lifeSpanDeviation: 600
-        angle: 0; angleDeviation: 360;
-        velocity: 100; velocityDeviation: 30
-        source: {
-            if (type == 0)
-                return "../../shared/pics/redStar.png";
-            else if (type == 1) 
-                return "../../shared/pics/blueStar.png";
-            else
-                return "../../shared/pics/greenStar.png";
+        Emitter {
+            id: particles
+            anchors.centerIn: parent
+            emitRate: 0
+            lifeSpan: 700
+            velocity: AngleDirection {angleVariation: 360; magnitude: 80; magnitudeVariation: 40}
+            size: 16
         }
     }
     //![3]
index ad4d39d..7f1c976 100755 (executable)
@@ -1,5 +1,6 @@
 /* This script file handles the game logic */
 .import QtQuick.LocalStorage 2.0 as Sql
+.import QtQuick 2.0 as Quick
 
 var maxColumn = 10;
 var maxRow = 15;
@@ -45,12 +46,12 @@ function startNewGame() {
 
 function createBlock(column, row) {
     if (component == null)
-        component = Qt.createComponent("content/BoomBlock.qml");
+        component = Qt.createComponent("BoomBlock.qml");
 
     // Note that if Block.qml was not a local file, component.status would be
     // Loading and we should wait for the component's statusChanged() signal to
     // know when the file is downloaded and ready before calling createObject().
-    if (component.status == Component.Ready) {
+    if (component.status == Quick.Component.Ready) {
         var dynamicObject = component.createObject(gameCanvas);
         if (dynamicObject == null) {
             console.log("error creating block");
index d4468d1..dbd13ff 100644 (file)
@@ -364,12 +364,12 @@ To fade out, we set \c dying to true instead of setting opacity to 0 when a bloc
 
 \section3 Adding particle effects
 
-Finally, we'll add a cool-looking particle effect to the blocks when they are destroyed. To do this, we first add a \l Particles element in
+Finally, we'll add a cool-looking particle effect to the blocks when they are destroyed. To do this, we first add a \l ParticleSystem in
 \c BoomBlock.qml, like so:
 
 \snippet tutorials/samegame/samegame4/content/BoomBlock.qml 3
 
-To fully understand this you should read the \l Particles documentation, but it's important to note that \c emissionRate is set
+To fully understand this you should read the \l Particles documentation, but it's important to note that \c emitRate is set
 to zero so that particles are not emitted normally.
 Also, we extend the \c dying State, which creates a burst of particles by calling the \c burst() method on the particles element. The code for the states now look
 like this: