summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-10-07 03:12:24 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-10-07 03:12:24 (GMT)
commit19d080d319dccac15654294af80530bed9ef11ea (patch)
tree239a0a0b4b3dc5905b0ecbee1416c62e170f8217 /examples/declarative/tutorials
parent5b77922f3782de4b96d6cf07ebb88419de130eac (diff)
downloadQt-19d080d319dccac15654294af80530bed9ef11ea.zip
Qt-19d080d319dccac15654294af80530bed9ef11ea.tar.gz
Qt-19d080d319dccac15654294af80530bed9ef11ea.tar.bz2
Switch Same Game tutorial to using snippets properly
Diffstat (limited to 'examples/declarative/tutorials')
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/Block.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/Button.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/samegame.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/samegame.js2
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/samegame.qml4
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Block.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Dialog.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.js4
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.qml6
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml10
-rwxr-xr-xexamples/declarative/tutorials/samegame/samegame4/content/samegame.js2
11 files changed, 37 insertions, 1 deletions
diff --git a/examples/declarative/tutorials/samegame/samegame1/Block.qml b/examples/declarative/tutorials/samegame/samegame1/Block.qml
index 228ac4e..b76e61a 100644
--- a/examples/declarative/tutorials/samegame/samegame1/Block.qml
+++ b/examples/declarative/tutorials/samegame/samegame1/Block.qml
@@ -1,3 +1,4 @@
+//![0]
import Qt 4.6
Item {
@@ -8,3 +9,4 @@ Item {
anchors.fill: parent
}
}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml
index 2354218..3846cf7 100644
--- a/examples/declarative/tutorials/samegame/samegame1/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame1/Button.qml
@@ -1,3 +1,4 @@
+//![0]
import Qt 4.6
Rectangle {
@@ -23,3 +24,4 @@ Rectangle {
id: txtItem; text: Container.text; anchors.centerIn: Container; color: activePalette.buttonText
}
}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml
index d18718d..8b32cae 100644
--- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml
@@ -1,3 +1,4 @@
+//![0]
import Qt 4.6
Rectangle {
@@ -36,3 +37,4 @@ Rectangle {
}
}
}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.js b/examples/declarative/tutorials/samegame/samegame2/samegame.js
index 064d87e..2bf68b5 100644
--- a/examples/declarative/tutorials/samegame/samegame2/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame2/samegame.js
@@ -1,3 +1,4 @@
+//![0]
//Note that X/Y referred to here are in game coordinates
var maxX = 10;//Nums are for tileSize 40
var maxY = 15;
@@ -57,3 +58,4 @@ function createBlock(xIdx,yIdx){
}
return true;
}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml
index e446fa4..78a3d83 100644
--- a/examples/declarative/tutorials/samegame/samegame2/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame2/samegame.qml
@@ -5,7 +5,9 @@ Rectangle {
width: 490; height: 720
SystemPalette { id: activePalette; colorGroup: Qt.Active }
+ //![2]
Script { source: "samegame.js" }
+ //![2]
Item {
width: parent.width; anchors.top: parent.top; anchors.bottom: ToolBar.top
@@ -23,11 +25,13 @@ Rectangle {
height: 32; width: parent.width
anchors.bottom: Screen.bottom
+ //![1]
Button {
id: btnA; text: "New Game"; onClicked: initBoard();
anchors.left: parent.left; anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
}
+ //![1]
Text {
id: Score
diff --git a/examples/declarative/tutorials/samegame/samegame3/Block.qml b/examples/declarative/tutorials/samegame/samegame3/Block.qml
index 2f28923..30a8d3a 100644
--- a/examples/declarative/tutorials/samegame/samegame3/Block.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/Block.qml
@@ -1,3 +1,4 @@
+//![0]
import Qt 4.6
Item {
@@ -17,3 +18,4 @@ Item {
anchors.fill: parent
}
}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
index 401d211..5fe6aa0 100644
--- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
@@ -1,3 +1,4 @@
+//![0]
import Qt 4.6
Rectangle {
@@ -19,3 +20,4 @@ Rectangle {
Text { id: MyText; anchors.centerIn: parent; text: "Hello World!" }
MouseRegion { id: mr; anchors.fill: parent; onClicked: forceClose(); }
}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js
index 16b349d..8fecfef 100644
--- a/examples/declarative/tutorials/samegame/samegame3/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.js
@@ -72,6 +72,7 @@ function createBlock(xIdx,yIdx){
var fillFound;//Set after a floodFill call to the number of tiles found
var floodBoard;//Set to 1 if the floodFill reaches off that node
//NOTE: Be careful with vars named x,y, as the calling object's x,y are still in scope
+//![1]
function handleClick(x,y)
{
xIdx = Math.floor(x/gameCanvas.tileSize);
@@ -88,6 +89,7 @@ function handleClick(x,y)
shuffleDown();
victoryCheck();
}
+//![1]
function floodFill(xIdx,yIdx,type)
{
@@ -156,6 +158,7 @@ function shuffleDown()
}
}
+//![2]
function victoryCheck()
{
//awards bonuses for no tiles left
@@ -169,6 +172,7 @@ function victoryCheck()
if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1)))
dialog.show("Game Over. Your score is " + gameCanvas.score);
}
+//![2]
//only floods up and right, to see if it can find adjacent same-typed tiles
function floodMoveCheck(xIdx, yIdx, type)
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
index ea43ab2..a0883da 100644
--- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
@@ -1,3 +1,4 @@
+//![0]
import Qt 4.6
Rectangle {
@@ -16,6 +17,7 @@ Rectangle {
fillMode: "PreserveAspectCrop"
}
+ //![1]
Item {
id: gameCanvas
property int score: 0
@@ -30,9 +32,12 @@ Rectangle {
anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y);
}
}
+ //![1]
}
+ //![2]
Dialog { id: dialog; anchors.centerIn: parent; z: 21 }
+ //![2]
Rectangle {
id: ToolBar
@@ -54,3 +59,4 @@ Rectangle {
}
}
}
+//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
index a495cd0..7ad8b07 100644
--- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
@@ -1,15 +1,18 @@
import Qt 4.6
Item { id:block
+ property int type: 0
property bool dying: false
+ //![1]
property bool spawned: false
- property int type: 0
property int targetX: 0
property int targetY: 0
x: SpringFollow { enabled: spawned; source: targetX; spring: 2; damping: 0.2 }
y: SpringFollow { source: targetY; spring: 2; damping: 0.2 }
+ //![1]
+ //![2]
Image { id: img
source: {
if(type == 0){
@@ -24,7 +27,9 @@ Item { id:block
opacity: Behavior { NumberAnimation { properties:"opacity"; duration: 200 } }
anchors.fill: parent
}
+ //![2]
+ //![3]
Particles { id: particles
width:1; height:1; anchors.centerIn: parent; opacity: 0
lifeSpan: 700; lifeSpanDeviation: 600; count:0; streamIn: false
@@ -39,7 +44,9 @@ Item { id:block
}
}
}
+ //![3]
+ //![4]
states: [
State{ name: "AliveState"; when: spawned == true && dying == false
PropertyChanges { target: img; opacity: 1 }
@@ -51,4 +58,5 @@ Item { id:block
PropertyChanges { target: img; opacity: 0 }
}
]
+ //![4]
}
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
index cf55b59..ce9c169 100755
--- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js
@@ -203,6 +203,7 @@ function createBlock(xIdx,yIdx){
return true;
}
+//![1]
function sendHighScore(name) {
var postman = new XMLHttpRequest()
var postData = "name="+name+"&score="+gameCanvas.score
@@ -215,3 +216,4 @@ function sendHighScore(name) {
}
postman.send(postData);
}
+//![1]