2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2021-11-08 15:46:32 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Particles
|
2011-04-27 12:13:26 +00:00
|
|
|
|
2023-03-23 16:12:52 +00:00
|
|
|
pragma ComponentBehavior: Bound
|
|
|
|
|
2011-09-20 07:16:36 +00:00
|
|
|
Rectangle {
|
2011-04-27 12:13:26 +00:00
|
|
|
id: root
|
|
|
|
color: "black"
|
|
|
|
width: 640
|
|
|
|
height: 480
|
2011-09-20 07:16:36 +00:00
|
|
|
ParticleSystem {
|
2011-04-27 12:13:26 +00:00
|
|
|
id: sys
|
|
|
|
}
|
2011-09-20 07:16:36 +00:00
|
|
|
ImageParticle {
|
2011-04-27 12:13:26 +00:00
|
|
|
system: sys
|
2013-04-01 20:45:21 +00:00
|
|
|
source: "qrc:///particleresources/glowdot.png"
|
2011-04-27 12:13:26 +00:00
|
|
|
color: "white"
|
|
|
|
colorVariation: 1.0
|
|
|
|
alpha: 0.1
|
|
|
|
}
|
2011-09-20 07:16:36 +00:00
|
|
|
|
|
|
|
Component {
|
2011-04-27 12:13:26 +00:00
|
|
|
id: emitterComp
|
2011-09-20 07:16:36 +00:00
|
|
|
Emitter {
|
2011-04-27 12:13:26 +00:00
|
|
|
id: container
|
2011-09-20 07:16:36 +00:00
|
|
|
Emitter {
|
2011-04-27 12:13:26 +00:00
|
|
|
id: emitMore
|
|
|
|
system: sys
|
2011-06-08 07:55:41 +00:00
|
|
|
emitRate: 128
|
|
|
|
lifeSpan: 600
|
|
|
|
size: 16
|
|
|
|
endSize: 8
|
2023-03-23 16:12:52 +00:00
|
|
|
velocity: AngleDirection {
|
|
|
|
angleVariation: 360
|
|
|
|
magnitude: 60
|
|
|
|
}
|
2011-04-27 12:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
property int life: 2600
|
|
|
|
property real targetX: 0
|
|
|
|
property real targetY: 0
|
2011-09-20 07:16:36 +00:00
|
|
|
function go() {
|
2023-03-23 16:12:52 +00:00
|
|
|
xAnim.start()
|
|
|
|
yAnim.start()
|
2011-09-06 00:40:21 +00:00
|
|
|
container.enabled = true
|
2011-04-27 12:13:26 +00:00
|
|
|
}
|
|
|
|
system: sys
|
2011-06-15 08:52:26 +00:00
|
|
|
emitRate: 32
|
2011-06-08 07:55:41 +00:00
|
|
|
lifeSpan: 600
|
|
|
|
size: 24
|
|
|
|
endSize: 8
|
2011-09-20 07:16:36 +00:00
|
|
|
NumberAnimation on x {
|
2011-04-27 12:13:26 +00:00
|
|
|
id: xAnim;
|
2023-03-23 16:12:52 +00:00
|
|
|
to: container.targetX
|
|
|
|
duration: container.life
|
2011-04-27 12:13:26 +00:00
|
|
|
running: false
|
|
|
|
}
|
2011-09-20 07:16:36 +00:00
|
|
|
NumberAnimation on y {
|
2011-04-27 12:13:26 +00:00
|
|
|
id: yAnim;
|
2023-03-23 16:12:52 +00:00
|
|
|
to: container.targetY
|
|
|
|
duration: container.life
|
2011-04-27 12:13:26 +00:00
|
|
|
running: false
|
|
|
|
}
|
2011-09-20 07:16:36 +00:00
|
|
|
Timer {
|
2023-03-23 16:12:52 +00:00
|
|
|
interval: container.life
|
2011-04-27 12:13:26 +00:00
|
|
|
running: true
|
2023-03-23 16:12:52 +00:00
|
|
|
onTriggered: container.destroy()
|
2011-04-27 12:13:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-09-20 07:16:36 +00:00
|
|
|
|
2023-03-23 16:12:52 +00:00
|
|
|
function customEmit(x, y) {
|
2012-06-18 04:13:31 +00:00
|
|
|
//! [0]
|
2023-03-23 16:12:52 +00:00
|
|
|
for (var i = 0; i < 8; i++) {
|
|
|
|
let obj = emitterComp.createObject(root)
|
2012-06-18 04:13:31 +00:00
|
|
|
obj.x = x
|
|
|
|
obj.y = y
|
|
|
|
obj.targetX = Math.random() * 240 - 120 + obj.x
|
|
|
|
obj.targetY = Math.random() * 240 - 120 + obj.y
|
|
|
|
obj.life = Math.round(Math.random() * 2400) + 200
|
|
|
|
obj.emitRate = Math.round(Math.random() * 32) + 32
|
2023-03-23 16:12:52 +00:00
|
|
|
obj.go()
|
2012-06-18 04:13:31 +00:00
|
|
|
}
|
|
|
|
//! [0]
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
interval: 10000
|
|
|
|
triggeredOnStart: true
|
|
|
|
running: true
|
|
|
|
repeat: true
|
2023-03-23 16:12:52 +00:00
|
|
|
onTriggered: root.customEmit(Math.random() * 320, Math.random() * 480)
|
2012-06-18 04:13:31 +00:00
|
|
|
}
|
2023-03-23 16:12:52 +00:00
|
|
|
TapHandler {
|
|
|
|
onTapped: function(event) { root.customEmit(event.pressPosition.x, event.pressPosition.y) }
|
2012-06-18 04:13:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2023-03-23 16:12:52 +00:00
|
|
|
text: qsTr("Click Somewhere")
|
2012-06-18 04:13:31 +00:00
|
|
|
color: "white"
|
|
|
|
font.pixelSize: 24
|
2011-04-27 12:13:26 +00:00
|
|
|
}
|
|
|
|
}
|