diff options
author | Morten Johan Sørvig <morten.sorvig@nokia.com> | 2010-03-25 07:42:21 (GMT) |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@nokia.com> | 2010-03-25 07:42:21 (GMT) |
commit | 20779098f4eb73f8789d704e1a2818ddbbf5b4d2 (patch) | |
tree | b1c4e3edb447ee47f9bc724f106d1bbefcff5456 /demos/declarative/snake/snake.qml | |
parent | 8cc346604ed1e1504964772613ed9fe531361f69 (diff) | |
parent | 194013d9db1b3e4ba6f56a864f3b64f523202948 (diff) | |
download | Qt-20779098f4eb73f8789d704e1a2818ddbbf5b4d2.zip Qt-20779098f4eb73f8789d704e1a2818ddbbf5b4d2.tar.gz Qt-20779098f4eb73f8789d704e1a2818ddbbf5b4d2.tar.bz2 |
Merge remote branch 'main/4.7' into 4.7
Conflicts:
demos/declarative/minehunt/minehunt.cpp
src/declarative/qml/qdeclarativecompiler.cpp
Diffstat (limited to 'demos/declarative/snake/snake.qml')
-rw-r--r-- | demos/declarative/snake/snake.qml | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/demos/declarative/snake/snake.qml b/demos/declarative/snake/snake.qml index 317c7de..68c2b78 100644 --- a/demos/declarative/snake/snake.qml +++ b/demos/declarative/snake/snake.qml @@ -1,13 +1,12 @@ import Qt 4.6 import "content" as Content +import "content/snake.js" as Logic Rectangle { id: screen; SystemPalette { id: activePalette } color: activePalette.window - Script { source: "content/snake.js" } - property int gridSize : 34 property int margin: 4 property int numRowsAvailable: Math.floor((height-32-2*margin)/gridSize) @@ -36,19 +35,19 @@ Rectangle { id: heartbeat; interval: heartbeatInterval; repeat: true - onTriggered: { move() } + onTriggered: { Logic.move() } } Timer { id: halfbeat; interval: halfbeatInterval; repeat: true running: heartbeat.running - onTriggered: { moveSkull() } + onTriggered: { Logic.moveSkull() } } Timer { interval: 700; - onTriggered: {startNewGame(); } + onTriggered: { Logic.startNewGame(); } } Timer { @@ -105,13 +104,13 @@ Rectangle { anchors.fill: parent onPressed: { if (!head || !heartbeat.running) { - startNewGame(); + Logic.startNewGame(); return; } if (direction == 0 || direction == 2) - scheduleDirection((mouseX > (head.x + head.width/2)) ? 1 : 3); + Logic.scheduleDirection((mouseX > (head.x + head.width/2)) ? 1 : 3); else - scheduleDirection((mouseY > (head.y + head.height/2)) ? 2 : 0); + Logic.scheduleDirection((mouseY > (head.y + head.height/2)) ? 2 : 0); } } } @@ -149,7 +148,7 @@ Rectangle { anchors.bottom: screen.bottom Content.Button { - id: btnA; text: "New Game"; onClicked: {startNewGame();} + id: btnA; text: "New Game"; onClicked: Logic.startNewGame(); anchors.left: parent.left; anchors.leftMargin: 3 anchors.verticalCenter: parent.verticalCenter } @@ -163,11 +162,11 @@ Rectangle { } focus: true - Keys.onSpacePressed: startNewGame(); - Keys.onLeftPressed: if (state == "starting" || direction != 1) scheduleDirection(3); - Keys.onRightPressed: if (state == "starting" || direction != 3) scheduleDirection(1); - Keys.onUpPressed: if (state == "starting" || direction != 2) scheduleDirection(0); - Keys.onDownPressed: if (state == "starting" || direction != 0) scheduleDirection(2); + Keys.onSpacePressed: Logic.startNewGame(); + Keys.onLeftPressed: if (state == "starting" || direction != 1) Logic.scheduleDirection(3); + Keys.onRightPressed: if (state == "starting" || direction != 3) Logic.scheduleDirection(1); + Keys.onUpPressed: if (state == "starting" || direction != 2) Logic.scheduleDirection(0); + Keys.onDownPressed: if (state == "starting" || direction != 0) Logic.scheduleDirection(2); states: [ State { |