summaryrefslogtreecommitdiffstats
path: root/examples/declarative/dynamic/qml/Sun.qml
blob: 796a37084d920d3886b848f4bf6b01d38bc566f6 (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
import Qt 4.6

Image {
    id: sun
    property bool created: false
    property string image: "../images/sun.png"
    onCreatedChanged: if(created){window.activeSuns++;}else{window.activeSuns--;}

    source: image; 
    z: 1

    //x and y get set when instantiated
    //head offscreen
    y: NumberAnimation {
        to: parent.height;
        duration: 10000;
        running: created
    }

    states: State {
        name: "OffScreen"; when: created && y > window.height / 2;//Below the ground
        StateChangeScript { script: { sun.created = false; sun.destroy() } }
    }
}