summaryrefslogtreecommitdiffstats
path: root/demos/declarative/samegame/SameGame.qml
blob: d476e8b2ea5be10d4cb025132ec0cf9ee99dd4dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import Qt 4.6

import "content"

Rectangle {
    id: page; width: 460; height: 700; color: activePalette.window
    Script { source: "content/samegame.js" }
    SystemPalette { id: activePalette; colorGroup: Qt.Active }
    Rectangle {
        id: gameCanvas
        property int score: 0
        z:20; y:20; color: "white"; border.width: 1
        width:parent.width - tileSize - (parent.width % tileSize);
        height:parent.height - tileSize - (parent.height % tileSize);
        anchors.horizontalCenter: parent.horizontalCenter
        Image { id:background;
            source: "content/pics/background.png"
            anchors.fill: parent
        }
        MouseRegion { id: gameMR
            anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y);
        }
    }

    Dialog { id: dialog; anchors.centerIn: parent; z: 21}
    Button {
        id: btnA; text: "New Game"; onClicked: {initBoard();}
        anchors.top: gameCanvas.bottom; anchors.topMargin: 4; anchors.left: gameCanvas.left;
    }
    Text {
        text: "Score: " + gameCanvas.score; width:100; font.pointSize:14
        anchors.top: gameCanvas.bottom; anchors.topMargin: 4; anchors.right: gameCanvas.right;
    }
}