Restart the timer on game restar
This commit is contained in:
parent
6ecfc64a79
commit
1ecfd36598
10
qml/Main.qml
10
qml/Main.qml
|
@ -53,7 +53,7 @@ ApplicationWindow {
|
||||||
Timer {
|
Timer {
|
||||||
id: gameTimer
|
id: gameTimer
|
||||||
interval: 1000
|
interval: 1000
|
||||||
running: true
|
running: GameState.gameWon === false
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: scoreBar.time += 1
|
onTriggered: scoreBar.time += 1
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,8 @@ ApplicationWindow {
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
|
|
||||||
|
onRestart: time = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show the foundation piles, throwaway pile & the draw stack on the first row
|
// Show the foundation piles, throwaway pile & the draw stack on the first row
|
||||||
|
@ -123,5 +125,9 @@ ApplicationWindow {
|
||||||
cardHeight: app.cardHeight
|
cardHeight: app.cardHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
WinOverlay {}
|
WinOverlay {
|
||||||
|
onRestart: {
|
||||||
|
scoreBar.time = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,15 @@ Rectangle {
|
||||||
property int time: 0
|
property int time: 0
|
||||||
property int moves: 0
|
property int moves: 0
|
||||||
|
|
||||||
|
signal restart
|
||||||
|
|
||||||
color: "lightgray"
|
color: "lightgray"
|
||||||
|
|
||||||
RoundButton {
|
RoundButton {
|
||||||
onClicked: GameState.dealCards()
|
onClicked: {
|
||||||
|
GameState.dealCards()
|
||||||
|
scoreBarRoot.restart()
|
||||||
|
}
|
||||||
|
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: parent.width * 0.02
|
anchors.leftMargin: parent.width * 0.02
|
||||||
|
|
|
@ -10,6 +10,8 @@ Rectangle {
|
||||||
visible: GameState.gameWon === true
|
visible: GameState.gameWon === true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
signal restart
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: winText
|
id: winText
|
||||||
|
|
||||||
|
@ -23,7 +25,10 @@ Rectangle {
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
text: "Restart"
|
text: "Restart"
|
||||||
onClicked: GameState.dealCards()
|
onClicked: {
|
||||||
|
GameState.dealCards();
|
||||||
|
winOverlay.restart();
|
||||||
|
}
|
||||||
anchors.top: winText.bottom
|
anchors.top: winText.bottom
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue