Warning, /education/gcompris/src/activities/penalty/GoalZone.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - GoalZone.qml 0002 * 0003 * SPDX-FileCopyrightText: 2017 Rohit Das <rohit.das950@gmail.com> 0004 * 0005 * SPDX-License-Identifier: GPL-3.0-or-later 0006 */ 0007 import QtQuick 2.12 0008 import './penalty.js' as Activity 0009 0010 Rectangle { 0011 anchors.left: parent.left 0012 anchors.right: parent.right 0013 anchors.bottom: parent.bottom 0014 anchors.top: parent.top 0015 anchors.topMargin: parent.height * 0.07 0016 property var progress: undefined 0017 state: "INITIAL" 0018 color: "transparent" 0019 0020 MouseArea { 0021 anchors.fill: parent 0022 acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MidButton 0023 /* enabled if the current zone has been clicked on or if the ball is at the initial position */ 0024 enabled: items.saveBallState === parent.state || (items.saveBallState === "INITIAL" && ball.x === items.ballX && ball.y === items.ballY) 0025 onClicked: changeBallState() 0026 } 0027 0028 function changeBallState() { 0029 instruction.text = "" 0030 0031 if(ball.state === "FAIL") { 0032 Activity.resetLevel() 0033 return 0034 } 0035 0036 /* This is a shoot */ 0037 if (items.saveBallState === "INITIAL") { 0038 items.saveBallState = state 0039 } 0040 0041 if(progress.ratio > 0) { 0042 /* Second click, stop animation */ 0043 progress.anim.running = false; 0044 0045 /* Play sound */ 0046 activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") 0047 0048 /* Success or not */ 0049 if(progress.ratio < 100) { 0050 /* Success */ 0051 ball.state = state 0052 } else { 0053 /* failure */ 0054 ball.state = "FAIL" 0055 } 0056 timerBonus.start() 0057 } else { 0058 /* First click, start animation*/ 0059 progress.anim.running = true; 0060 0061 /* Play sound */ 0062 activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/flip.wav") 0063 } 0064 } 0065 }