Only free context if the owning QV8ContextResource gets destroyed
[profile/ivi/qtdeclarative.git] / examples / particles / affectors / content / spritegoal.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
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 Digia Plc and its Subsidiary(-ies) nor the names
21 **     of its contributors may be used to endorse or promote products derived
22 **     from this software without specific prior written permission.
23 **
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 Item {
45     id: root
46     width: 360
47     height: 540
48     MouseArea {
49         id: ma
50         anchors.fill: parent
51     }
52
53     ParticleSystem { id: sys }
54     Image {
55         source: "../../images/finalfrontier.png"
56         transformOrigin: Item.Center
57         anchors.centerIn: parent
58         NumberAnimation on rotation {
59             from: 0
60             to: 360
61             duration: 200000
62             loops: Animation.Infinite
63         }
64
65     }
66     ImageParticle {
67         system: sys
68         groups: ["starfield"]
69         source: "../../images/star.png"
70         colorVariation: 0.3
71         color: "white"
72     }
73     Emitter {
74         id: starField
75         system: sys
76         group: "starfield"
77
78         emitRate: 80
79         lifeSpan: 2500
80
81         anchors.centerIn: parent
82
83         //acceleration: AngledDirection {angleVariation: 360; magnitude: 200}//Is this a better effect, more consistent velocity?
84         acceleration: PointDirection { xVariation: 200; yVariation: 200; }
85
86         size: 0
87         endSize: 80
88         sizeVariation: 10
89     }
90     Emitter {
91         system: sys
92         group: "meteor"
93         emitRate: 12
94         lifeSpan: 5000
95         acceleration: PointDirection { xVariation: 80; yVariation: 80; }
96         size: 15
97         endSize: 300
98         anchors.centerIn: parent
99      }
100     ImageParticle {
101         system: sys
102         groups: ["meteor"]
103         sprites:[Sprite {
104                 id: spinState
105                 name: "spinning"
106                 source: "../../images/meteor.png"
107                 frameCount: 35
108                 frameDuration: 40
109                 randomStart: true
110                 to: {"explode":0, "spinning":1}
111             },Sprite {
112                 name: "explode"
113                 source: "../../images/_explo.png"
114                 frameCount: 22
115                 frameDuration: 40
116                 to: {"nullFrame":1}
117             },Sprite {//Not sure if this is needed, but seemed easiest
118                 name: "nullFrame"
119                 source: "../../images/nullRock.png"
120                 frameCount: 1
121                 frameDuration: 1000
122             }
123         ]
124     }
125     //! [0]
126     SpriteGoal {
127         groups: ["meteor"]
128         system: sys
129         goalState: "explode"
130         jump: true
131         anchors.fill: rocketShip
132         width: 60
133         height: 60
134     }
135     //! [0]
136     Image {
137         id: rocketShip
138         source: "../../images/rocket.png"
139         anchors.centerIn: holder
140         rotation: (circle.percent+0.25) * 360
141         z: 2
142     }
143     Item {
144         id: holder
145         x: circle.x - Math.sin(circle.percent * 6.28316530714)*200
146         y: circle.y + Math.cos(circle.percent * 6.28316530714)*200
147         z: 1
148     }
149
150     Item {
151         id: circle
152         x: root.width / 1.2 
153         y: root.height / 1.7
154         property real percent: 0
155
156         SequentialAnimation on percent {
157             id: circleAnim1
158             loops: Animation.Infinite
159             running: true
160             NumberAnimation {
161             duration: 4000
162             from: 1
163             to: 0
164             }
165
166         }
167     }
168
169     ImageParticle {
170         z:0 
171         system: sys
172         groups: ["exhaust"]
173         source: "../../images/particle4.png"
174
175         color: "orange"
176         SequentialAnimation on color {
177             loops: Animation.Infinite
178             ColorAnimation {
179                 from: "red"
180                 to: "cyan"
181                 duration: 1000
182             }
183             ColorAnimation {
184                 from: "cyan"
185                 to: "red"
186                 duration: 1000
187             }
188         }
189
190         colorVariation: 0.2
191     }
192
193     Emitter {
194         id: trailsNormal2
195         system: sys
196         group: "exhaust"
197
198         emitRate: 300
199         lifeSpan: 500
200
201         y: holder.y
202         x: holder.x 
203
204         velocity: PointDirection { xVariation: 40; yVariation: 40; }
205         velocityFromMovement: 16
206
207         acceleration: PointDirection { xVariation: 10; yVariation: 10; }
208
209         size: 4
210         sizeVariation: 4
211     }
212 }