summaryrefslogtreecommitdiffstats
path: root/demos/declarative/samegame/content/SpinBlock.qml
blob: 2597bfbc89266e16537aed419e4ed2b707e67f1c (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
Item { id:block
    //Note: These properties are the interface used to control the blocks
    property bool dying: false
    property bool spawned: false
    property bool selected: false
    property int type: 0
    property int targetY: 0
    property int targetX: 0

    AnimatedImage {
        source: if(type == 0) {
                    "pics/gnome/redStone.gif"; 
                } else if (type == 1) { 
                    "pics/gnome/blueStone.gif"; 
                } else {
                    "pics/gnome/greenStone.gif"; 
                }
        paused: !selected
    }
    opacity: 0
    y: targetY
    x: targetX
    y: Behavior { NumberAnimation { properties:"y"; duration: 200 } }
    x: Behavior { NumberAnimation { properties:"x"; duration: 200 } }
    opacity: Behavior { NumberAnimation { properties:"opacity"; duration: 200 } }

    states: [

        State{ name: "AliveState"; when: spawned == true && dying == false
            SetProperties { target: block; opacity: 1 }
        },
        State{ name: "DeathState"; when: dying == true
            SetProperties { target: block; opacity: 0 }
        }
    ]
}