Warning, /education/gcompris/src/activities/planegame/Cloud.qml is written in an unsupported language. File is not indexed.
0001 /* gcompris - Cloud.qml
0002
0003 SPDX-FileCopyrightText: 2014 Johnny Jazeix <jazeix@gmail.com>
0004
0005 2003, 2014: Bruno Coudoin: initial version
0006 2014: Johnny Jazeix: Qt port
0007
0008 SPDX-License-Identifier: GPL-3.0-or-later
0009 */
0010 import QtQuick 2.12
0011 import "planegame.js" as Activity
0012 import "../../core"
0013 import GCompris 1.0
0014
0015 Image {
0016 id: cloud
0017 property Item background
0018 property alias text: number.text
0019 property double heightRatio: 1
0020
0021 /* An helper property to remember if a cloud has been wrongly touched */
0022 property bool touched: false
0023
0024 sourceSize.height: 60 * ApplicationInfo.ratio
0025 height: sourceSize.height * heightRatio
0026
0027 state: "normal"
0028 fillMode: Image.PreserveAspectFit
0029
0030 z: 5
0031
0032 signal done
0033 signal touch
0034
0035 onDone: {
0036 particles.burst(50)
0037 opacityTimer.start()
0038 }
0039
0040 onTouch: {
0041 touched = true
0042 state = "storm"
0043 }
0044
0045 GCText {
0046 id: number
0047 anchors.horizontalCenter: cloud.horizontalCenter
0048 anchors.verticalCenter: cloud.verticalCenter
0049 color: "black"
0050 font.bold: true
0051 fontSize: 18
0052 }
0053
0054 Component.onCompleted: {
0055 x = -cloud.width - 1
0056 y = Activity.getRandomInt(0, background.height - (cloud.height + Activity.items.bar.height))
0057 }
0058
0059 Behavior on x { PropertyAnimation { duration: 20000 } }
0060 Behavior on opacity { PropertyAnimation { duration: 400 } }
0061
0062 Timer {
0063 id: stormy
0064 interval: 2000
0065 running: false
0066 repeat: false
0067 onTriggered: cloud.state = "normal"
0068 }
0069
0070 states: [
0071 State {
0072 name: "normal"
0073 PropertyChanges {
0074 target: cloud
0075 source: Activity.url + "resource/cloud.svg"
0076 }
0077 },
0078 State {
0079 name: "storm"
0080 PropertyChanges {
0081 target: cloud
0082 source: Activity.url + "resource/cloud_storm.svg"
0083 }
0084 StateChangeScript {
0085 script: stormy.start()
0086 }
0087 }
0088 ]
0089
0090 Timer {
0091 id: opacityTimer
0092 running: false
0093 repeat: false
0094 interval: 500
0095 onTriggered: opacity = 0
0096 }
0097
0098 ParticleSystemStarLoader {
0099 id: particles
0100 anchors.fill: parent
0101 clip: false
0102 }
0103
0104 }