diff --git a/examples/M-modules/quick/sokoban/README.txt b/examples/M-modules/quick/sokoban/README.txt index 687ba7b..998ac46 100644 --- a/examples/M-modules/quick/sokoban/README.txt +++ b/examples/M-modules/quick/sokoban/README.txt @@ -22,10 +22,9 @@ This example shows how to dynamically create QML items from Lisp. The ability to call Lisp from QML comes in handy for the Lisp functions which need to wait for eventual running animations to finish. -See: +See e.g. class: - "qml/items/player.qml" - "qml/items/box.qml" + "qml/ext/NumberAnimation_notify.qml" TIP diff --git a/examples/M-modules/quick/sokoban/qml/ext/NumberAnimation_notify.qml b/examples/M-modules/quick/sokoban/qml/ext/NumberAnimation_notify.qml new file mode 100644 index 0000000..81b93ed --- /dev/null +++ b/examples/M-modules/quick/sokoban/qml/ext/NumberAnimation_notify.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import EQL5 1.0 + +NumberAnimation { + onRunningChanged: { Lisp.call("qsoko:animation-change", running) } +} + diff --git a/examples/M-modules/quick/sokoban/qml/ext/ScaleAnimator_notify.qml b/examples/M-modules/quick/sokoban/qml/ext/ScaleAnimator_notify.qml new file mode 100644 index 0000000..4aeb90b --- /dev/null +++ b/examples/M-modules/quick/sokoban/qml/ext/ScaleAnimator_notify.qml @@ -0,0 +1,6 @@ +import QtQuick 2.2 +import EQL5 1.0 + +ScaleAnimator { + onRunningChanged: { Lisp.call("qsoko:animation-change", running) } +} diff --git a/examples/M-modules/quick/sokoban/qml/ext/SequentialAnimation_notify.qml b/examples/M-modules/quick/sokoban/qml/ext/SequentialAnimation_notify.qml new file mode 100644 index 0000000..2c1d23d --- /dev/null +++ b/examples/M-modules/quick/sokoban/qml/ext/SequentialAnimation_notify.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 +import EQL5 1.0 + +SequentialAnimation { + onRunningChanged: { Lisp.call("qsoko:animation-change", running) } +} + diff --git a/examples/M-modules/quick/sokoban/qml/items/box.qml b/examples/M-modules/quick/sokoban/qml/items/box.qml index 34a27c0..8144ea6 100644 --- a/examples/M-modules/quick/sokoban/qml/items/box.qml +++ b/examples/M-modules/quick/sokoban/qml/items/box.qml @@ -1,21 +1,18 @@ import QtQuick 2.0 -import EQL5 1.0 +import "../ext/" Image { Behavior on x { - NumberAnimation { + NumberAnimation_notify { duration: 150 easing.type: Easing.InQuart - onRunningChanged: { Lisp.call("qsoko:animation-change", running) } } } Behavior on y { - NumberAnimation { + NumberAnimation_notify { duration: 150 easing.type: Easing.InQuart - onRunningChanged: { Lisp.call("qsoko:animation-change", running) } } } } - diff --git a/examples/M-modules/quick/sokoban/qml/items/box2.qml b/examples/M-modules/quick/sokoban/qml/items/box2.qml index 7a4bbf9..5983ceb 100644 --- a/examples/M-modules/quick/sokoban/qml/items/box2.qml +++ b/examples/M-modules/quick/sokoban/qml/items/box2.qml @@ -1,31 +1,28 @@ import QtQuick 2.0 -import EQL5 1.0 +import "../ext/" Image { id: box2 Behavior on x { - NumberAnimation { + NumberAnimation_notify { duration: 150 easing.type: Easing.InQuart - onRunningChanged: { Lisp.call("qsoko:animation-change", running) } } } Behavior on y { - NumberAnimation { + NumberAnimation_notify { duration: 150 easing.type: Easing.InQuart - onRunningChanged: { Lisp.call("qsoko:animation-change", running) } } } // final animation - SequentialAnimation { + SequentialAnimation_notify { objectName: "wiggle" loops: 5 - onRunningChanged: { Lisp.call("qsoko:animation-change", running) } RotationAnimation { target: box2 diff --git a/examples/M-modules/quick/sokoban/qml/items/player.qml b/examples/M-modules/quick/sokoban/qml/items/player.qml index 2ab5b48..8cb1fab 100644 --- a/examples/M-modules/quick/sokoban/qml/items/player.qml +++ b/examples/M-modules/quick/sokoban/qml/items/player.qml @@ -1,20 +1,18 @@ import QtQuick 2.0 -import EQL5 1.0 +import "../ext/" Image { Behavior on x { - NumberAnimation { + NumberAnimation_notify { duration: 120 easing.type: Easing.InOutSine - onRunningChanged: { Lisp.call("qsoko:animation-change", running) } } } Behavior on y { - NumberAnimation { + NumberAnimation_notify { duration: 120 easing.type: Easing.InOutSine - onRunningChanged: { Lisp.call("qsoko:animation-change", running) } } } } diff --git a/examples/M-modules/quick/sokoban/qml/sokoban.qml b/examples/M-modules/quick/sokoban/qml/sokoban.qml index 629ee73..f049a05 100644 --- a/examples/M-modules/quick/sokoban/qml/sokoban.qml +++ b/examples/M-modules/quick/sokoban/qml/sokoban.qml @@ -1,5 +1,5 @@ import QtQuick 2.2 -import EQL5 1.0 +import "ext/" Rectangle { id: root @@ -18,21 +18,19 @@ Rectangle { // level change animations - ScaleAnimator { + ScaleAnimator_notify { objectName: "zoomOut" target: root from: 0.8 to: 0 duration: 250 - onRunningChanged: { Lisp.call("qsoko:animation-change", running) } } - ScaleAnimator { + ScaleAnimator_notify { objectName: "zoomIn" target: root from: 0 to: 0.8 duration: 250 - onRunningChanged: { Lisp.call("qsoko:animation-change", running) } } }