summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZeno Albisser <zeno.albisser@nokia.com>2010-08-17 04:16:11 -0400
committerZeno Albisser <zeno.albisser@nokia.com>2010-08-17 04:16:11 -0400
commit2eab8277e57d887b8bb3795730c3af701b34d803 (patch)
tree98a87fe68aa5d5352d3bec6a78694601a57c0617
parent67fb52c95ff8925057cd4d1d86a9221af3482a22 (diff)
parent0eb47cc0de2bdec25f1f44217e477abca2953d0f (diff)
Merge branch 'master' of gitorious.org:stuff/qml-dashboard
-rwxr-xr-xanimals/Animal.qml6
-rw-r--r--animals/memory.js17
-rw-r--r--animals/memory.qml34
3 files changed, 53 insertions, 4 deletions
diff --git a/animals/Animal.qml b/animals/Animal.qml
index 3e598ee..dd4c628 100755
--- a/animals/Animal.qml
+++ b/animals/Animal.qml
@@ -133,7 +133,11 @@ Rectangle {
animalRectangle.x += gesture.delta.x;
animalRectangle.y += gesture.delta.y;
}
- onFinished: animalRectangle.z = 0;
+ onFinished: {
+ animalRectangle.z = 0;
+
+ console.log("velo: " + gesture.horizontalVelocity);
+ }
}
Pinch {
diff --git a/animals/memory.js b/animals/memory.js
index 1e2167c..689a480 100644
--- a/animals/memory.js
+++ b/animals/memory.js
@@ -2,8 +2,9 @@ var component;
var maxRow = 3;
var maxColumn = 4;
var maxIndex = maxColumn * maxRow;
-var finished = new Array();
-var positions = new Array();
+var finished = [];
+var positions = [];
+var allTiles = [];
var animals = [ "ArtFavor_Cartoon_Sheep.png", "danko_Friendly_rabbit.png",
"lemmling_Cartoon_cow.png", "PeterM_Sad_cat.png",
@@ -11,6 +12,17 @@ var animals = [ "ArtFavor_Cartoon_Sheep.png", "danko_Friendly_rabbit.png",
"Machovka_lady_bug.png", "carlitos_Green_Worm.png",
"Gerald_G_Rubber_Duck.png", "molumen_Green_sitting_frog.png"]
+function reset() {
+ positions = [];
+ finished = [];
+
+ for (var i = 0; i < allTiles.length; i++) {
+ allTiles[i].destroy();
+ }
+
+ createBoard();
+}
+
function createBoard() {
var currentTime = new Date();
var seed = currentTime.getSeconds() * currentTime.getHours();
@@ -46,6 +58,7 @@ function createAnimal(image, animalId, column, row) {
dynamicObject.y = 5 + row * (gameBoard.blockSize+5);
dynamicObject.width = gameBoard.blockSize;
dynamicObject.height = gameBoard.blockSize;
+ allTiles.push(dynamicObject);
} else {
console.log("error loading block component");
console.log(component.errorString());
diff --git a/animals/memory.qml b/animals/memory.qml
index 1a51a9e..b510545 100644
--- a/animals/memory.qml
+++ b/animals/memory.qml
@@ -46,9 +46,11 @@ Rectangle {
Rectangle {
id: close;
+ z: 100;
width: 40;
height: 40;
- color: "transparent";
+ color: "white";
+ opacity: 0.7;
border.color: "black";
radius: 5;
anchors.right: parent.right;
@@ -71,6 +73,36 @@ Rectangle {
}
}
+ Rectangle {
+ id: restart;
+ z: 100;
+ width: 120;
+ height: 60;
+ color: "white";
+ opacity: 0.7;
+ border.color: "black";
+ radius: 5;
+ anchors.right: parent.right;
+ anchors.bottom: parent.bottom;
+
+ Text {
+ anchors.centerIn: parent
+ text: "restart";
+ font.pointSize: 24;
+ }
+
+ GestureArea {
+ anchors.fill: parent;
+ TapAndHold {
+ onFinished: {
+ console.log("restart");
+ victoryText.visible = false;
+ MemoryLogic.reset();
+ }
+ }
+ }
+ }
+
function animalTapped(animal) {
MemoryLogic.tileClicked(animal);
}