e874c78d891eef7fec5c7f5bbe4e12f2f3f5b02b
[profile/ivi/qtdeclarative.git] / examples / particles / affectors / content / groupgoal.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the examples of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
10 **
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
13 ** met:
14 **   * Redistributions of source code must retain the above copyright
15 **     notice, this list of conditions and the following disclaimer.
16 **   * Redistributions in binary form must reproduce the above copyright
17 **     notice, this list of conditions and the following disclaimer in
18 **     the documentation and/or other materials provided with the
19 **     distribution.
20 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
21 **     the names of its contributors may be used to endorse or promote
22 **     products derived from this software without specific prior written
23 **     permission.
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40
41 import QtQuick 2.0
42 import QtQuick.Particles 2.0
43
44
45 Rectangle {
46     id: root
47     width: 360
48     height: 600
49     color: "black"
50
51     property int score: 0
52     Text {
53         color: "white"
54         anchors.right: parent.right
55         text: score
56     }
57
58     ParticleSystem {
59         id: particles
60         anchors.fill: parent
61         // ![unlit]
62         ParticleGroup {
63             name: "unlit"
64             duration: 1000
65             to: {"lighting":1, "unlit":99}
66             ImageParticle {
67                 source: "../../images/particleA.png"
68                 colorVariation: 0.1
69                 color: "#2060160f"
70             }
71             GroupGoal {
72                 whenCollidingWith: ["lit"]
73                 goalState: "lighting"
74                 jump: true
75             }
76         }
77         // ![unlit]
78         // ![lighting]
79         ParticleGroup {
80             name: "lighting"
81             duration: 100
82             to: {"lit":1}
83         }
84         // ![lighting]
85         // ![lit]
86         ParticleGroup {
87             name: "lit"
88             duration: 10000
89             onEntered: score++;
90             TrailEmitter {
91                 id: fireballFlame
92                 group: "flame"
93
94                 emitRatePerParticle: 48
95                 lifeSpan: 200
96                 emitWidth: 8
97                 emitHeight: 8
98
99                 size: 24
100                 sizeVariation: 8
101                 endSize: 4
102             }
103
104             TrailEmitter {
105                 id: fireballSmoke
106                 group: "smoke"
107         // ![lit]
108
109                 emitRatePerParticle: 120
110                 lifeSpan: 2000
111                 emitWidth: 16
112                 emitHeight: 16
113
114                 speed: PointDirection {yVariation: 16; xVariation: 16}
115                 acceleration: PointDirection {y: -16}
116
117                 size: 24
118                 sizeVariation: 8
119                 endSize: 8
120             }
121         }
122
123         ImageParticle {
124             id: smoke
125             anchors.fill: parent
126             groups: ["smoke"]
127             source: "../../images/particle.png"
128             colorVariation: 0
129             color: "#00111111"
130         }
131         ImageParticle {
132             id: pilot
133             anchors.fill: parent
134             groups: ["pilot"]
135             source: "../../images/particle.png"
136             redVariation: 0.01
137             blueVariation: 0.4
138             color: "#0010004f"
139         }
140         ImageParticle {
141             id: flame
142             anchors.fill: parent
143             groups: ["flame", "lit", "lighting"]
144             source: "../../images/particleA.png"
145             colorVariation: 0.1
146             color: "#00ff400f"
147         }
148
149         Emitter {
150             height: parent.height/2
151             emitRate: 4
152             lifeSpan: 4000//TODO: Infinite & kill zone
153             size: 24
154             sizeVariation: 4
155             speed: PointDirection {x:120; xVariation: 80; yVariation: 50}
156             acceleration: PointDirection {y:120}
157             group: "unlit"
158         }
159
160         Emitter {
161             id: flamer
162             x: 100
163             y: 300
164             group: "pilot"
165             emitRate: 80
166             lifeSpan: 600
167             size: 24
168             sizeVariation: 2
169             endSize: 0
170             speed: PointDirection { y:-100; yVariation: 4; xVariation: 4 }
171             // ![groupgoal-pilot]
172             GroupGoal {
173                 groups: ["unlit"]
174                 goalState: "lit"
175                 jump: true
176                 system: particles
177                 x: -15
178                 y: -55
179                 height: 75
180                 width: 30
181                 shape: MaskShape {source: "../../images/matchmask.png"}
182             }
183             // ![groupgoal-pilot]
184         }
185         // ![groupgoal-ma]
186         //Click to enflame
187         GroupGoal {
188             groups: ["unlit"]
189             goalState: "lighting"
190             jump: true
191             enabled: ma.pressed
192             width: 18
193             height: 18
194             x: ma.mouseX - width/2
195             y: ma.mouseY - height/2
196         }
197         // ![groupgoal-ma]
198         MouseArea {
199             id: ma
200             anchors.fill: parent
201         }
202     }
203 }