1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the examples of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
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
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
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."
39 ****************************************************************************/
42 import QtQuick.Particles 2.0
43 import "content/script.js" as Script
57 Behavior on opacity {NumberAnimation {}}
60 anchors.centerIn: parent
72 height: parent.height - 132/2
75 velocity: PointDirection { x: 32; xVariation: 8 }
77 lifeSpan: Emitter.InfiniteLife
82 x: parent.width + 132/2
89 source: "../trails/../images/star.png"
90 color: "lightsteelblue"
107 NumberAnimation on scale {
114 source: "../asteroid/../images/rocket.png"
115 anchors.centerIn: parent
118 anchors.bottom: parent.bottom
119 anchors.horizontalCenter: parent.horizontalCenter
120 text: "A new ship has arrived!"
124 property Item alertItem;
126 //resetter.active = false
128 alertItem = alertDelegate.createObject(root);
129 alertItem.x = root.width/2 - alertItem.width/2
130 alertItem.y = root.height/2 - alertItem.height/2
131 spawnFireworks.pulse(200);
135 Keys.onSpacePressed: alert();
143 //resetter.active = true;
144 mp.take(alertItem, true);
145 centerEmitter.burst(1);
152 pointY: root.height/2
155 anchors.centerIn: parent
156 width: parent.width/2
157 height: parent.height/2
159 affectedParameter: Attractor.Position
163 velocity: PointDirection { x: 32; xVariation: 8;}
165 lifeSpan: 12000 //TODO: A -1 or something which does 'infinite'? (but need disable fade first)
169 anchors.centerIn: parent
172 //TODO: Zoom in effect
182 y: parent.height/2 - 64
188 velocity: AngleDirection { magnitude: 160; magnitudeVariation: 120; angleVariation: 90; angle: 270 }
189 acceleration: PointDirection { y: 160 }
191 Item { x: -1000; y: -1000 //offscreen
192 Repeater {//Load them here, add to system on completed
194 delegate: theDelegate
197 RssModel {id: theModel; tags:"particle,particles"}
203 property real myRand: Math.random();//'depth'
204 z: Math.floor(myRand * 100)
205 scale: (myRand + 1.0)/2;
206 //TODO: Darken based on 'depth'
209 //ItemParticle.onAttached: console.log("I'm in" + x + "," + y + ":" + opacity);
210 ItemParticle.onDetached: mp.take(container);//respawns
213 if (state == "selected") {
214 console.log("Taking " + index);
215 mp.freeze(container);
217 console.log("Returning " +index);
218 mp.unfreeze(container);
223 anchors.centerIn: parent
224 smooth: true; source: "http://" + Script.getImagePath(content); cache: true
225 fillMode: Image.PreserveAspectFit;
226 width: parent.width-4; height: parent.height-4
227 onStatusChanged: if (img.status == Image.Ready) {
233 anchors.bottom: parent.bottom
235 horizontalAlignment: Text.AlignHCenter
236 elide: Text.ElideRight
242 onClicked: container.state == "selected" ? container.state = "" : container.state = "selected"
261 transitions: Transition {
264 SequentialAnimation {
265 ScriptAction {script: container.manage();}
267 ParentAnimation {NumberAnimation { properties: "x,y" }}//Doesn't work, particles takes control of x,y instantly
268 NumberAnimation { properties: "width, height, z, rotation" }