diff --git a/src/activities/penalty/Penalty.qml b/src/activities/penalty/Penalty.qml --- a/src/activities/penalty/Penalty.qml +++ b/src/activities/penalty/Penalty.qml @@ -54,14 +54,29 @@ } /* This is a shoot */ - var progress = progressTop - if (saveBallState == "LEFT") { - progress = progressLeft - } - else if(saveBallState == "RIGHT") { - progress = progressRight + var progress = (items.progress === null) ? null : items.progress + if (items.saveBallState === "INITIAL" && progress === null) { + + items.saveBallState = saveBallState + if (saveBallState === "LEFT") { + progress = progressLeft + rectRight.enabled = false + rectTop.enabled = false + } + else if (saveBallState === "RIGHT") { + progress = progressRight + rectLeft.enabled = false + rectTop.enabled = false + } + else { + progress = progressTop + rectRight.enabled = false + rectLeft.enabled = false + } } + items.progress = progress + if(progress.ratio > 0) { /* Second click, stop animation */ progress.anim.running = false; @@ -72,11 +87,12 @@ /* Success or not */ if(progress.ratio < 100) { /* Success */ - ball.state = saveBallState + ball.state = items.saveBallState } else { /* failure */ ball.state = "FAIL" } + rectLeft.enabled = rectTop.enabled = rectRight.enabled = true timerBonus.start() } else { /* First click, start animation*/ @@ -102,6 +118,7 @@ MouseArea { anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton + enabled: items.isEnabled onClicked: { if(mouse.button) { changeBallState("LEFT") @@ -123,6 +140,7 @@ MouseArea { anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton + enabled: items.isEnabled onClicked: { if(mouse.button) { changeBallState("CENTER") @@ -146,6 +164,7 @@ MouseArea { anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton + enabled: items.isEnabled onClicked: { if(mouse.button) { changeBallState("RIGHT") @@ -167,6 +186,11 @@ property alias bonus: bonus property int duration : 0 property int progressBarOpacity : 40 + property string saveBallState: "INITIAL" + property var progress: null + property double ballX: ball.parent.width/2 - ball.width/2; + property double ballY: ball.parent.height*0.77 - ball.height/2 + property bool isEnabled: (ball.state === "INITIAL" && ball.x === items.ballX && ball.y === items.ballY) } onStart: { Activity.start(items) } @@ -432,9 +456,12 @@ acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton onClicked: { ball.state = "INITIAL" + items.saveBallState = "INITIAL" progressRight.ratio = 0 progressLeft.ratio = 0 progressTop.ratio = 0 + items.progress = null + rectLeft.enabled = rectTop.enabled = rectRight.enabled = true } } } diff --git a/src/activities/penalty/penalty.js b/src/activities/penalty/penalty.js --- a/src/activities/penalty/penalty.js +++ b/src/activities/penalty/penalty.js @@ -31,6 +31,7 @@ function start(items_) { items = items_ currentLevel = 0 + initLevel() } @@ -54,9 +55,11 @@ function resetLevel() { items.ball.state = "INITIAL" + items.saveBallState = "INITIAL" items.progressRight.ratio = 0 items.progressLeft.ratio = 0 items.progressTop.ratio = 0 + items.progress = null } function nextLevel() {