summaryrefslogtreecommitdiff
path: root/demos/declarative/samegame/SameGame.qml
blob: 0e5bb0f05c777faebaffa0e16b8f1359f32d05af (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
35
36
import "content"

Rect {
    width: 400
    height: 700
    color: "white"
    Script { source: "content/samegame.js" }
    Rect{
        property int score: 0
        x:20; y:20; width:360; height:600; id: gameCanvas;
        color: "white"
        pen.width: 1
        Image { id:background;
            source: "content/pics/qtlogo.png"
            anchors.fill: parent
        }

        MouseRegion { id: gameMR; anchors.fill: parent;
            onClicked: handleClick(mouseX, mouseY);
        }
    }
    HorizontalLayout {
        anchors.top: gameCanvas.bottom
        anchors.topMargin: 10
        anchors.horizontalCenter: parent.horizontalCenter
        MediaButton { id: btnA; text: "New Game"; onClicked: {initBoard();} }
        MediaButton { id: btnB; text: "Swap Theme"; onClicked: {swapTileSrc(); dialog.opacity = 1;}
        }
        Text{ text: "Score: " + gameCanvas.score; width:100 }
    }
    SameDialog {
        id: dialog
        anchors.centeredIn: parent
        text: "Takes effect next game."
    }
}