summaryrefslogtreecommitdiffstats
path: root/CoffeeTweed/Cup.qml
blob: 93fc385b6428cd7b2cc9694aa1932f677d55f94e (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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import Qt 4.7

Item {
    id: coffee_cup
    width: 190; height: 480

    function return_to_ashes() {
        coffee_cup.state = "";
    }

    Image {
        id: cup_plate
        source: "images/coffee_plate.png"; y: 365
    }

    Item {
        id: cup_full
        width: 135; height: 138; x: 7; y: 280
        Image { source: "images/cup_back.png"; }

        Item { id: cup_content; Image { source: "images/cup_content.png"; } }
        Item { id: cup_front; Image { source: "images/cup_front.png"; } }
    }

    Item {
        id: cup_empty
        width: 135; height: 138; x: 7; y: 280; opacity: 0
        Image { source: "images/cup_empty.png"; }
    }

    Item {
        id: cup_smoke
        width: 233; height: 258; y: 45; x: -13; opacity: 1
        Image { source: "images/cup_smoke.png" }
    }

    Item {
        id: cup_running
        width: 135; height: 188; x: 7; y: -228; opacity: 0
        Image { source: "images/cup_blur.png"; }
    }

    states: [
        State{
            name: "less_one"
        }
    ]

    transitions: [
        Transition {
            from: ""
            to: "less_one"

            SequentialAnimation{

                // Empty the cup and fade the smoke
                ParallelAnimation {
                    PropertyAnimation { target: cup_smoke; property: "opacity"; to: 0; duration: 500; }
                    PropertyAnimation { target: cup_content; property: "y"; to: 25; duration: 500; }
                }

                // Change the full cup composition by the empty cup
                    PropertyAction { target: cup_empty; property: "opacity"; value: 1 }
                    PropertyAction { target: cup_full; property: "opacity"; value: 0; }

                // Pause for coffee
                PauseAnimation { duration: 100; }

                // Fade out the empty cup
                PropertyAnimation { target: cup_empty; property: "opacity"; to: 0; duration: 200; }

                // Send the empty cup to the top and update the number
                    PropertyAction { target: cup_empty; property: "y"; value: -188; }

                // Turn on the blur and empty cups
                    PropertyAction { target: cup_running; property: "opacity"; value: 1; }
                    PropertyAction { target: cup_empty; property: "opacity"; value: 1; }

                // Clean cup coming!
                ParallelAnimation {
                    PropertyAnimation { target: cup_running; property: "y"; to: 235; duration: 300; }
                    PropertyAnimation { target: cup_empty; property: "y"; to: 285; duration: 300; }
                }

                // Landing in the plate
                ParallelAnimation {
                    PropertyAnimation { target: cup_empty; property: "y"; to: 280; duration: 150; }
                    PropertyAnimation { target: cup_running; property: "opacity"; to: 0; duration: 200; }
                }

                // Get the blured cup to the original place
                    PropertyAction { target: cup_running; property: "y"; value: -228; }

                // Wait for the waiter
                PauseAnimation { duration: 500; }

                // Change the empty cup by the full cup composition
                    PropertyAction { target: cup_full; property: "opacity"; value: 1; }
                    PropertyAction { target: cup_empty; property: "opacity"; value: 0; }

                // Here is your coffee, sir
                PropertyAnimation { target: cup_content; property: "y"; to: 0; duration: 400; }
                PropertyAnimation { target: cup_smoke; property: "opacity"; to: 1; duration: 700; }

                // Ready for the next turn
                ScriptAction { script: return_to_ashes() }
            }

        }
    ]

}