summaryrefslogtreecommitdiffstats
path: root/examples/demos/samegame/content/SmokeText.qml
blob: a05ce27c96a880ea1d7aee1527e9697faa204bdc (plain)
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
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Particles

Item {
    id: smokeText
    z: 10
    property alias source: img.source
    property alias system: emitter.system
    property int playerNum: 1
    function play() {
        anim.running = true;
    }
    anchors.centerIn: parent
    Image {
        opacity: 0
        id: img
        anchors.centerIn: parent
        rotation: smokeText.playerNum == 1 ? -8 : -5
        Emitter {
            id: emitter
            group: "smoke"
            anchors.fill: parent
            shape: MaskShape { source: img.source }
            enabled: false
            emitRate: 1000
            lifeSpan: 600
            size: 64
            endSize: 32
            velocity: AngleDirection { angleVariation: 360; magnitudeVariation: 160 }
        }
    }
    SequentialAnimation {
        id: anim
        running: false
        PauseAnimation { duration: 500}
        ParallelAnimation {
            NumberAnimation { target: img; property: "opacity"; from: 0.1; to: 1.0 }
            NumberAnimation { target: img; property: "scale"; from: 0.1; to: 1.0 }
        }
        PauseAnimation { duration: 250}
        ScriptAction { script: emitter.pulse(100); }
        NumberAnimation { target: img; property: "opacity"; from: 1.0; to: 0.0 }
    }
}