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