2022-06-03 11:26:02 +00:00
|
|
|
// Copyright (C) 2017 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2018-06-26 13:53:07 +00:00
|
|
|
|
2020-12-01 12:57:32 +00:00
|
|
|
import QtQuick
|
|
|
|
import QtQuick.Particles
|
2018-06-26 13:53:07 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: block
|
|
|
|
property bool dying: false
|
|
|
|
property bool spawned: false
|
|
|
|
property int type: 0
|
|
|
|
property ParticleSystem particleSystem
|
|
|
|
|
|
|
|
Behavior on x {
|
2024-09-02 14:11:53 +00:00
|
|
|
enabled: block.spawned;
|
2018-06-26 13:53:07 +00:00
|
|
|
NumberAnimation{ easing.type: Easing.OutBounce }
|
|
|
|
}
|
|
|
|
Behavior on y {
|
|
|
|
NumberAnimation{ easing.type: Easing.InQuad }
|
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: img
|
|
|
|
source: {
|
2024-09-02 14:11:53 +00:00
|
|
|
if (block.type == 0){
|
2018-06-26 13:53:07 +00:00
|
|
|
"gfx/red-puzzle.png";
|
2024-09-02 14:11:53 +00:00
|
|
|
} else if (block.type == 1) {
|
2018-06-26 13:53:07 +00:00
|
|
|
"gfx/blue-puzzle.png";
|
2024-09-02 14:11:53 +00:00
|
|
|
} else if (block.type == 2) {
|
2018-06-26 13:53:07 +00:00
|
|
|
"gfx/green-puzzle.png";
|
|
|
|
} else {
|
|
|
|
"gfx/yellow-puzzle.png";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
opacity: 0
|
|
|
|
Behavior on opacity { NumberAnimation { duration: 200 } }
|
|
|
|
anchors.centerIn: parent
|
|
|
|
anchors.verticalCenterOffset: -4
|
|
|
|
anchors.horizontalCenterOffset: 4
|
|
|
|
}
|
|
|
|
|
|
|
|
//Foreground particles
|
|
|
|
BlockEmitter {
|
|
|
|
id: particles
|
2024-09-02 14:11:53 +00:00
|
|
|
system: block.particleSystem
|
2018-06-26 13:53:07 +00:00
|
|
|
group: {
|
2024-09-02 14:11:53 +00:00
|
|
|
if (block.type == 0){
|
2018-06-26 13:53:07 +00:00
|
|
|
"red";
|
2024-09-02 14:11:53 +00:00
|
|
|
} else if (block.type == 1) {
|
2018-06-26 13:53:07 +00:00
|
|
|
"blue";
|
2024-09-02 14:11:53 +00:00
|
|
|
} else if (block.type == 2) {
|
2018-06-26 13:53:07 +00:00
|
|
|
"green";
|
|
|
|
} else {
|
|
|
|
"yellow";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
anchors.fill: parent
|
|
|
|
}
|
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
2024-09-02 14:11:53 +00:00
|
|
|
name: "AliveState"; when: block.spawned == true && block.dying == false
|
|
|
|
PropertyChanges { img.opacity: 1 }
|
2018-06-26 13:53:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
State {
|
2024-09-02 14:11:53 +00:00
|
|
|
name: "DeathState"; when: block.dying == true
|
|
|
|
PropertyChanges { img.scale: 2 }
|
2018-06-26 13:53:07 +00:00
|
|
|
StateChangeScript { script: particles.pulse(200); }
|
2024-09-02 14:11:53 +00:00
|
|
|
PropertyChanges { img.opacity: 0 }
|
2018-06-26 13:53:07 +00:00
|
|
|
StateChangeScript { script: block.destroy(1000); }
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|