-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSnow.qml
More file actions
79 lines (65 loc) · 1.69 KB
/
Snow.qml
File metadata and controls
79 lines (65 loc) · 1.69 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
67
68
69
70
71
72
73
74
75
76
77
78
79
//Snow
import QtQuick 2.1
Item {
id: snow
width: 75
height: 75
x : ((Math.random() * parent.width)-40);
y : -80;
Item {
id: sprite
anchors.centerIn: parent
height: parent.height
width: parent.width
clip: true
function randomNumber(from, to) {
return Math.floor(Math.random() * (to - from + 1) + from);
}
property int spritecolor: randomNumber(1, 6)
transform: Rotation {
id: rotator
origin{
x: 60
y: 110
}
angle: 0
}
SequentialAnimation {
id: shake
PropertyAnimation { easing.type: Easing.InQuad; duration: 400; target: rotator; property: "angle"; to: 5 }
PropertyAnimation { easing.type: Easing.InQuad; duration: 400; target: rotator; property: "angle"; to: -5 }
}
Timer {
running: true
repeat: true
interval: 800
onTriggered: {
shake.restart();
}
}
Image {
id: spriteImage
source: "https://raw.githubusercontent.com/ToonSoftwareCollective/toonanimations/main/Snow.png"
y:0
x:0
}
}
function randomNumber(from, to) {
return Math.floor(Math.random() * (to - from + 1) + from);
}
property int speed: randomNumber(1, 4)
Timer {
interval: 50
running: true
repeat: true
onTriggered: {
snow.y += speed;
if (isNxt && (snow.y - snow.height)> 700) {
snow.destroy();
}
if (!isNxt && (snow.y - snow.height) > 550) {
snow.destroy();
}
}
}
}