simplify QML in "sokoban" example

This commit is contained in:
polos 2017-03-06 08:49:40 +01:00
parent ab935d300b
commit 96cd6e9c99
8 changed files with 35 additions and 26 deletions

View file

@ -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

View file

@ -0,0 +1,7 @@
import QtQuick 2.0
import EQL5 1.0
NumberAnimation {
onRunningChanged: { Lisp.call("qsoko:animation-change", running) }
}

View file

@ -0,0 +1,6 @@
import QtQuick 2.2
import EQL5 1.0
ScaleAnimator {
onRunningChanged: { Lisp.call("qsoko:animation-change", running) }
}

View file

@ -0,0 +1,7 @@
import QtQuick 2.0
import EQL5 1.0
SequentialAnimation {
onRunningChanged: { Lisp.call("qsoko:animation-change", running) }
}

View file

@ -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) }
}
}
}

View file

@ -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

View file

@ -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) }
}
}
}

View file

@ -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) }
}
}