summaryrefslogtreecommitdiffstats
path: root/examples/declarative/toys/dynamic/qml/Sun.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/toys/dynamic/qml/Sun.qml')
-rw-r--r--examples/declarative/toys/dynamic/qml/Sun.qml38
1 files changed, 38 insertions, 0 deletions
diff --git a/examples/declarative/toys/dynamic/qml/Sun.qml b/examples/declarative/toys/dynamic/qml/Sun.qml
new file mode 100644
index 0000000..43dcb9a
--- /dev/null
+++ b/examples/declarative/toys/dynamic/qml/Sun.qml
@@ -0,0 +1,38 @@
+import Qt 4.7
+
+Image {
+ id: sun
+
+ property bool created: false
+ property string image: "../images/sun.png"
+
+ source: image
+
+ // once item is created, start moving offscreen
+ NumberAnimation on y {
+ to: window.height / 2
+ running: created
+ onRunningChanged: {
+ if (running)
+ duration = (window.height - sun.y) * 10;
+ else
+ state = "OffScreen"
+ }
+ }
+
+ states: State {
+ name: "OffScreen"
+ StateChangeScript {
+ script: { sun.created = false; sun.destroy() }
+ }
+ }
+
+ onCreatedChanged: {
+ if (created) {
+ sun.z = 1; // above the sky but below the ground layer
+ window.activeSuns++;
+ } else {
+ window.activeSuns--;
+ }
+ }
+}