Index: src/activities/penalty/ActivityInfo.qml =================================================================== --- src/activities/penalty/ActivityInfo.qml +++ src/activities/penalty/ActivityInfo.qml @@ -24,12 +24,11 @@ author: "Stephane Mankowski <stephane@mankowski.fr>" demo: true title: qsTr("Penalty kick") - description: qsTr("Double click or double tap on the ball to score a goal.") + description: qsTr("Double click or double tap on the side of the goal to score.") // intro: "Double click or double tap on the ball to score a goal." goal: "" prerequisite: "" - manual: qsTr("Double click or double tap on the ball to kick it. " + - "You can double click the left right or middle mouse button. " + + manual: qsTr("Double click or double tap on the side of the goal to kick it in. " + "If you lose, Tux catches the ball. You must click on it to " + "bring it back to its former position") credit: "" Index: src/activities/penalty/Penalty.qml =================================================================== --- src/activities/penalty/Penalty.qml +++ src/activities/penalty/Penalty.qml @@ -45,6 +45,167 @@ activity.stop.connect(stop) } + //To enable tapping/clicking on left side of goal + Rectangle{ + id: maleft + //anchors.fill: parent.left + width: 475 + height: 300 + x: 100 + y: 50 + color: "transparent" + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton + onClicked: { + instruction.text = "" + + if(ball.state === "FAIL") { + Activity.resetLevel() + return + } + + /* This is a shoot */ + var progress = progressTop + if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { + progress = progressLeft + } + + if(progress.ratio > 0) { + /* Second click, stop animation */ + progress.anim.running = false; + + /* Play sound */ + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") + + /* Success or not */ + if(progress.ratio < 100) { + /* Success */ + ball.state = "LEFT" + } else { + /* failure */ + ball.state = "FAIL" + } + timerBonus.start() + } else { + /* First click, start animation*/ + progress.anim.running = true; + + /* Play sound */ + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") + } + } + } + } + + //To enable tapping/clicking on top of goal + Rectangle{ + id: matop + width: 600 + height: 175 + x: 575 + y: 50 + color: "transparent" + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton + onClicked: { + instruction.text = "" + + if(ball.state === "FAIL") { + Activity.resetLevel() + return + } + + /* This is a shoot */ + var progress = progressTop + if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { + + } + + if(progress.ratio > 0) { + /* Second click, stop animation */ + progress.anim.running = false; + + /* Play sound */ + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") + + /* Success or not */ + if(progress.ratio < 100) { + /* Success */ + ball.state = "CENTER" + } else { + /* failure */ + ball.state = "FAIL" + } + timerBonus.start() + } else { + /* First click, start animation*/ + progress.anim.running = true; + + /* Play sound */ + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") + } + } + } + } + + //To enable tapping/clicking on right side of goal + Rectangle{ + id: maright + //anchors.fill: parent.right + width: 475 + height: 300 + x: 800 + y: 50 + color: "transparent" + + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton + onClicked: { + instruction.text = "" + + if(ball.state === "FAIL") { + Activity.resetLevel() + return + } + + /* This is a shoot */ + var progress = progressTop + if (mouse.button == Qt.LeftButton | mouse.button == Qt.RightButton | mouse.button == Qt.MidButton) { + progress = progressRight + } + + if(progress.ratio > 0) { + /* Second click, stop animation */ + progress.anim.running = false; + + /* Play sound */ + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") + + /* Success or not */ + if(progress.ratio < 100) { + /* Success */ + ball.state = "RIGHT" + } else { + /* failure */ + ball.state = "FAIL" + } + timerBonus.start() + } else { + /* First click, start animation*/ + progress.anim.running = true; + + /* Play sound */ + activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") + } + } + } + } + // Add here the QML items you need to access in javascript QtObject { id: items @@ -275,7 +436,7 @@ } PropertyChanges { target: instruction - text: qsTr("Double click or double tap on the ball to kick it.") + text: qsTr("Double click or double tap on the side of the goal you want to put the ball in.") } }, State { @@ -283,8 +444,8 @@ PropertyChanges { target: ball; sourceSize.width: 75 * ApplicationInfo.ratio - x: background.width * 0.8; - y: background.height * 0.3 + x: background.width * (Math.random() * (0.8 - 0.6) + 0.6); + y: background.height * (Math.random() * (0.4 - 0.1) + 0.1) } }, State { @@ -292,8 +453,8 @@ PropertyChanges { target: ball; sourceSize.width: 75 * ApplicationInfo.ratio - x: background.width * 0.2; - y: background.height * 0.3 + x: background.width * (Math.random() * (0.4 - 0.1) + 0.1); + y: background.height * (Math.random() * (0.4 - 0.1) + 0.1) } }, State { @@ -320,56 +481,14 @@ } ] - MouseArea { + MouseArea{ anchors.fill: parent acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton - onClicked: { - instruction.text = "" - - if(ball.state === "FAIL") { - Activity.resetLevel() - return - } - - /* This is a shoot */ - var progress = progressTop - if (mouse.button == Qt.LeftButton) { - progress = progressLeft - } else if (mouse.button == Qt.RightButton) { - progress = progressRight - } else if (mouse.button == Qt.MidButton) { - progress = progressTop - } - - if(progress.ratio > 0) { - /* Second click, stop animation */ - progress.anim.running = false; - - /* Play sound */ - activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") - - /* Success or not */ - if(progress.ratio < 100) { - /* Success */ - if(progress === progressLeft) { - ball.state = "LEFT" - } else if(progress === progressRight) { - ball.state = "RIGHT" - } else { - ball.state = "CENTER" - } - } else { - /* failure */ - ball.state = "FAIL" - } - timerBonus.start() - } else { - /* First click, start animation*/ - progress.anim.running = true; - - /* Play sound */ - activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") - } + onClicked:{ + ball.state = "INITIAL" + progressRight.ratio = 0 + progressLeft.ratio = 0 + progressTop.ratio = 0 } } }