Warning, /education/gcompris/src/activities/football/Football.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - football.qml 0002 * 0003 * SPDX-FileCopyrightText: 2014 Bruno Coudoin <bruno.coudoin@gcompris.net> 0004 * 0005 * Authors: 0006 * Bruno Coudoin <bruno.coudoin@gcompris.net> (GTK+ version) 0007 * Bruno Coudoin <bruno.coudoin@gcompris.net> (Qt Quick port) 0008 * Bharath M S <brat.197@gmail.com> (Qt Quick port) 0009 * 0010 * SPDX-License-Identifier: GPL-3.0-or-later 0011 */ 0012 import QtQuick 2.12 0013 0014 import "../../core" 0015 import "football.js" as Activity 0016 0017 import GCompris 1.0 0018 ActivityBase { 0019 id: activity 0020 0021 onStart: focus = true 0022 onStop: {} 0023 0024 pageComponent: Rectangle { 0025 id: background 0026 anchors.fill: parent 0027 signal start 0028 signal stop 0029 0030 Component.onCompleted: { 0031 activity.start.connect(start) 0032 activity.stop.connect(stop) 0033 } 0034 // Add here the QML items you need to access in javascript 0035 QtObject { 0036 id: items 0037 property Item main: activity.main 0038 property alias background: background 0039 property alias bar: bar 0040 property alias field: field 0041 property alias border: border 0042 property alias ball: ball 0043 property alias line: line 0044 property alias tux: tux 0045 property alias moveTux: moveTux 0046 property alias moveUp: moveUp 0047 property alias moveDown: moveDown 0048 property int currentLevel: activity.currentLevel 0049 property alias bonus: bonus 0050 property alias timer: timer 0051 property GCSfx audioEffects: activity.audioEffects 0052 } 0053 0054 onStart: { Activity.start(items) } 0055 onStop: { Activity.stop() } 0056 /* To modify when screen size changes */ 0057 onHeightChanged: { 0058 moveUp.to = 0 0059 moveDown.to = background.height * 0.75 - tux.height 0060 moveTux.restart() 0061 } 0062 0063 Image { 0064 id: field 0065 source: Activity.url + "background.svg" 0066 anchors.fill: parent 0067 Rectangle { 0068 id: border 0069 height: parent.height * 0.75 0070 width: parent.width * 0.856 0071 x: parent.width * 0.075 0072 y: parent.height * 0.125 0073 color: "transparent" 0074 Rectangle { 0075 id: line 0076 opacity: 0.0 0077 color: "#ee4b4b" 0078 transformOrigin: Item.TopLeft 0079 } 0080 Image { 0081 id: ball 0082 source: Activity.url + "ball.svg" 0083 sourceSize.height: 50 * ApplicationInfo.ratio 0084 z: 10 0085 onXChanged: if(line.opacity === 1) ballTouchArea.updateLine(); 0086 onYChanged: if(line.opacity === 1) ballTouchArea.updateLine(); 0087 0088 property int halfSize: width * 0.5 0089 0090 MultiPointTouchArea { 0091 id: ballTouchArea 0092 enabled: !bonus.isPlaying 0093 anchors.fill: parent 0094 touchPoints: [ TouchPoint { id: point1 }] 0095 property var pointPosition: Qt.point(0, 0) 0096 onReleased: { 0097 line.opacity = 0 0098 Activity.startMotion(point1.x - ball.halfSize, 0099 point1.y - ball.halfSize) 0100 activity.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/brick.wav") 0101 } 0102 onPressed: line.opacity = 1 0103 onTouchUpdated: { 0104 pointPosition = ball.mapToItem(border, point1.x, point1.y); 0105 updateLine(); 0106 } 0107 0108 function updateLine() { 0109 Activity.drawLine(pointPosition.x, pointPosition.y, ball.x + ball.halfSize, ball.y + ball.halfSize); 0110 } 0111 } 0112 } 0113 Image { 0114 id: tux 0115 source: Activity.url+"tux_top.svg" 0116 sourceSize.height: 80 * ApplicationInfo.ratio 0117 x: border.width - tux.width 0118 y: border.height / 2 0119 SequentialAnimation on y { 0120 id: moveTux 0121 loops: Animation.Infinite 0122 running: true 0123 PropertyAnimation { 0124 id: moveUp 0125 duration: 800 0126 easing.type: Easing.InOutQuad 0127 } 0128 PropertyAnimation { 0129 id: moveDown 0130 duration: 800 0131 easing.type: Easing.InOutQuad 0132 } 0133 } 0134 } 0135 } 0136 Rectangle { 0137 width: parent.width * 0.1 0138 height: parent.height * 0.75 0139 color: "blue" 0140 anchors.top: border.top 0141 anchors.left: border.right 0142 z: 10 0143 opacity: 0.3 0144 } 0145 } 0146 0147 Timer { 0148 id: timer 0149 interval: 16; 0150 running: false; 0151 repeat: true 0152 onTriggered: Activity.ballMotion() 0153 } 0154 0155 DialogHelp { 0156 id: dialogHelp 0157 onClose: home() 0158 } 0159 0160 Bar { 0161 id: bar 0162 level: items.currentLevel + 1 0163 content: BarEnumContent { value: help | home | level } 0164 onHelpClicked: { 0165 displayDialog(dialogHelp) 0166 } 0167 onPreviousLevelClicked: Activity.previousLevel() 0168 onNextLevelClicked: Activity.nextLevel() 0169 onHomeClicked: activity.home() 0170 } 0171 0172 Bonus { 0173 id: bonus 0174 Component.onCompleted: win.connect(Activity.nextLevel) 0175 } 0176 } 0177 }