Warning, /education/gcompris/src/activities/explore_farm_animals/AnimalLevels.qml is written in an unsupported language. File is not indexed.

0001 /* GCompris - AnimalLevels.qml
0002 *
0003 * SPDX-FileCopyrightText: 2015 Ayush Agrawal <ayushagrawal288@gmail.com>
0004 *
0005 * Authors:
0006 *   Beth Hadley <bethmhadley@gmail.com> (GTK+ version)
0007 *   Ayush Agrawal <ayushagrawal288@gmail.com> (Qt Quick port)
0008 *   Djalil MESLI <djalilmesli@gmail.com> (Qt Quick port)
0009 *   Johnny Jazeix <jazeix@gmail.com> (Qt Quick port)
0010 *
0011 *   SPDX-License-Identifier: GPL-3.0-or-later
0012 */
0013 import QtQuick 2.12
0014 import GCompris 1.0
0015 
0016 import "../../core"
0017 import "explore-level.js" as Activity
0018 
0019 Image {
0020     id: animalImg
0021     width: animalWidth
0022     height: animalHeight
0023     sourceSize.width: width
0024     sourceSize.height: height
0025     fillMode: Image.PreserveAspectFit
0026 
0027     property string name: name
0028     property alias starVisible: star.visible
0029     property int questionId
0030     property string title
0031     property string description
0032     property string imageSource
0033     property string question
0034     property string audio
0035 
0036     signal displayDescription(var animal)
0037 
0038     SequentialAnimation {
0039         id: anim
0040         running: true
0041         loops: 1
0042 
0043         NumberAnimation {
0044             target: animalImg
0045             property: "rotation"
0046             from: 0; to: 360
0047             duration: 400 + Math.floor(Math.random() * 400)
0048             easing.type: Easing.InOutQuad
0049         }
0050     }
0051 
0052     Image {
0053         id: star
0054         anchors.verticalCenter: animalImg.bottom
0055         anchors.horizontalCenter: animalImg.horizontalCenter
0056         width: background.playWidth * 0.05
0057         height: width
0058         visible: false
0059         source:"qrc:/gcompris/src/core/resource/star.png"
0060     }
0061 
0062     MultiPointTouchArea {
0063         id: touchArea
0064         anchors.centerIn: parent
0065         width: parent.width
0066         height: parent.height
0067         touchPoints: [ TouchPoint { id: point1 } ]
0068         mouseEnabled: progressbar.currentSubLevel != progressbar.numberOfSubLevels && !items.buttonsBlocked
0069 
0070         onPressed: {
0071             if(items.progressbar.currentSubLevel >= progressbar.numberOfSubLevels) {
0072                 return
0073             }
0074             var questionTargetId = items.questionOrder[Activity.items.progressbar.currentSubLevel]
0075             Activity.items.instruction.visible = false
0076             if (Activity.items.score.currentSubLevel === 1) {
0077                 if(animalImg.audio) {
0078                     audioVoices.play(animalImg.audio);
0079                 }
0080                 displayDescription(animalImg)
0081                 star.visible = true;
0082             } else {
0083                 items.buttonsBlocked = true;
0084                 if (questionId === questionTargetId) {
0085                     animWin.start();
0086                     items.progressbar.currentSubLevel ++;
0087                     items.progressbar.playWinAnimation();
0088                     items.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/completetask.wav");
0089                 } else {
0090                     items.errorRectangle.parent = animalImg;
0091                     items.errorRectangle.startAnimation();
0092                     items.audioEffects.play("qrc:/gcompris/src/core/resource/sounds/crash.wav");
0093                 }
0094             }
0095         }
0096     }
0097 
0098     SequentialAnimation {
0099         id: animWin
0100         running: false
0101         loops: 1
0102         NumberAnimation {
0103             target: animalImg
0104             property: "rotation"
0105             from: 0; to: 360
0106             duration: 600
0107             easing.type: Easing.InOutQuad
0108         }
0109     }
0110 }