forked from ToonSoftwareCollective/toonanimations
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFirework2.qml
More file actions
66 lines (52 loc) · 1.46 KB
/
Firework2.qml
File metadata and controls
66 lines (52 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import QtQuick 2.0
Item {
id: firework
property bool destroyed: false
width: 160
height: 160
x :((Math.random() * parent.width-77))
y : parent.height
Item {
id: sprite
property int frame: 0
property string pngname : "https://raw.githubusercontent.com/ToonSoftwareCollective/toonanimations/main/fire" + randomNumber(1, 4) + ".png"
anchors.centerIn: parent
height: parent.height
width: parent.height
clip: true
SequentialAnimation {
id: move
NumberAnimation { target: firework; property: "y"; to: 400 - (explodeheight*50); duration: 100 }
}
Timer {
running: true
repeat: true
interval: 100
onTriggered: {
move.restart();
}
}
Image {
id: spriteImage
source: sprite.pngname
y: 0
x: -154*sprite.frame
}
}
Timer {
interval:(75+explodespeed*50)
running: true
repeat: true
onTriggered: {
sprite.frame++;
if (sprite.frame >= 8) {
firework.destroy()
}
}
}
function randomNumber(from, to) {
return Math.floor(Math.random() * (to - from + 1) + from);
}
property int explodeheight: randomNumber(3, 8)
property int explodespeed: randomNumber(1, 4)
}