Warning, /education/gcompris/src/activities/gletters/FallingImage.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - Word.qml 0002 * 0003 * SPDX-FileCopyrightText: 2014 Holger Kaelberer <holger.k@elberer.de> 0004 * 0005 * Authors: 0006 * Bruno Coudoin <bruno.coudoin@gcompris.net> (GTK+ version) 0007 * Holger Kaelberer <holger.k@elberer.de> (Qt Quick port) 0008 * 0009 * 0010 * SPDX-License-Identifier: GPL-3.0-or-later 0011 */ 0012 import QtQuick 2.12 0013 import QtGraphicalEffects 1.0 0014 import GCompris 1.0 0015 0016 import "../../core" 0017 import "gletters.js" as Activity 0018 0019 Item { 0020 id: word 0021 0022 width: image.width 0023 height: image.height 0024 0025 /// index into text.split("") where next typed match should occur 0026 property int unmatchedIndex: 0; 0027 property string text 0028 property alias image: image.source; 0029 property bool wonState: false 0030 0031 signal won 0032 0033 onWon: { 0034 wonState = true 0035 particle.burst(30) 0036 dropShadow.opacity = 0 0037 fadeout.restart(); 0038 } 0039 0040 Component.onCompleted: { 0041 // make sure our word is completely visible 0042 if (x + width >= parent.width) 0043 x = parent.width - width; 0044 } 0045 0046 PropertyAnimation { 0047 id: fadeout 0048 target: word; 0049 property: "opacity" 0050 to: 0 0051 duration: 1000 0052 onStopped: Activity.deleteWord(word); 0053 } 0054 0055 function checkMatch(c) 0056 { 0057 // We are in the ending animation 0058 if (wonState) 0059 return 0060 0061 var chars = text.split(""); 0062 if (chars[unmatchedIndex] === c) { 0063 unmatchedIndex++; 0064 return true; 0065 } else { 0066 unmatchedIndex = 0; 0067 return false; 0068 } 0069 } 0070 0071 function startMoving(dur) 0072 { 0073 down.duration = dur; 0074 down.restart(); 0075 } 0076 0077 function isCompleted() 0078 { 0079 return (unmatchedIndex === text.length); 0080 } 0081 0082 Image { 0083 id: image 0084 // FIXME, the size should be passed from the caller 0085 sourceSize.height: 106 * ApplicationInfo.ratio 0086 0087 ParticleSystemStarLoader { 0088 id: particle 0089 clip: false 0090 } 0091 } 0092 0093 DropShadow { 0094 id: dropShadow 0095 anchors.fill: image 0096 cached: false 0097 horizontalOffset: 1 0098 verticalOffset: 1 0099 radius: 3.0 0100 samples: 16 0101 color: "#422a2a2a" 0102 source: image 0103 } 0104 0105 NumberAnimation { 0106 id: down 0107 target: word 0108 property: "y" 0109 to: parent.height 0110 duration: 10000 0111 0112 onStopped: { 0113 Activity.audioCrashPlay(); 0114 Activity.appendRandomWord(word.text) 0115 Activity.deleteWord(word); 0116 } 0117 } 0118 }