Warning, /education/gcompris/src/activities/clickgame/Fish.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - Fish.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 * Timothée Giet <animtim@gmail.com> (animation refactoring) 0009 * 0010 * SPDX-License-Identifier: GPL-3.0-or-later 0011 */ 0012 import QtQuick 2.12 0013 import QtQuick.Particles 2.12 0014 import "clickgame.js" as Activity 0015 import "../../core" 0016 import GCompris 1.0 0017 0018 AnimatedSprite { 0019 id: fish 0020 property Item activity 0021 property Item background 0022 property Item bar 0023 property int duration: 5000 0024 property int minY: Activity.items.score.y + Activity.items.score.height 0025 property int maxY: bar.y - fish.height 0026 property int minX: fish.width * -1.2 0027 property int maxX: background.width + fish.width * 0.2 0028 property real xSpeed: 10 0029 property real ySpeed: 1 0030 frameRate: 2 0031 interpolate: true 0032 0033 signal animTrigger 0034 0035 Component.onCompleted: { 0036 background.animTrigger.connect(animTrigger) 0037 } 0038 0039 transform: Rotation { 0040 id: rotate; origin.x: width / 2; origin.y: 0; axis { x: 0; y: 1; z: 0 } angle: 0 0041 } 0042 0043 onAnimTrigger: { 0044 if(x >= maxX) { 0045 rotate.angle = 180; 0046 fish.xSpeed *= -1; 0047 x = maxX 0048 } else if(x <= minX) { 0049 rotate.angle = 0; 0050 fish.xSpeed *= -1; 0051 x = minX 0052 } 0053 if(y >= maxY) { 0054 ySpeed *= -1; 0055 y = maxY; 0056 }else if(y <= minY) { 0057 ySpeed *= -1; 0058 y = minY; 0059 } 0060 if(Activity.items.currentLevel > 0) { 0061 fish.y += fish.ySpeed; 0062 } 0063 fish.x += fish.xSpeed 0064 } 0065 0066 Behavior on opacity { PropertyAnimation { duration: 500 } } 0067 0068 MouseArea { 0069 anchors.fill: parent 0070 onClicked: { 0071 background.animTrigger.disconnect(animTrigger) 0072 parent.opacity = 0 0073 enabled = false 0074 activity.audioEffects.play("qrc:/gcompris/src/activities/clickgame/resource/drip.wav") 0075 Activity.fishKilled() 0076 particles.burst(40); 0077 } 0078 } 0079 0080 Loader { 0081 id: bubbleEffect 0082 anchors.fill: parent 0083 active: ApplicationInfo.hasShader 0084 sourceComponent: ParticleSystem { 0085 anchors.fill: parent 0086 Emitter { 0087 x: parent.x + parent.width * 0.8 0088 y: parent.y + parent.height / 2 0089 width: 1 0090 height: 1 0091 emitRate: 0.5 0092 lifeSpan: 1000 0093 lifeSpanVariation: 2500 0094 acceleration: PointDirection { 0095 x: -10 0096 xVariation: 10 0097 y: -20 0098 yVariation: 10 0099 } 0100 velocity: PointDirection { 0101 x: -20 0102 xVariation: 10 0103 y: -20 0104 yVariation: 10 0105 } 0106 size: 16 0107 sizeVariation: 8 0108 } 0109 0110 ImageParticle { 0111 source: "qrc:/gcompris/src/activities/clickgame/resource/bubble.svg" 0112 } 0113 } 0114 } 0115 0116 ParticleSystemStarLoader { 0117 id: particles 0118 clip: false 0119 } 0120 }