From 4a30e784182a41d54d8b908ba47d948ed4172236 Mon Sep 17 00:00:00 2001 From: Wolfgang Beck Date: Fri, 23 Sep 2011 15:05:58 +1000 Subject: MTMW-288 add Maze (TiltSensor Example) Change-Id: I023e4baeb82facfb7d2f97c3b6076d7f1e816e16 Reviewed-on: http://codereview.qt-project.org/5434 Reviewed-by: Wolfgang Beck --- examples/sensors/maze/LabyrinthSquare.qml | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 examples/sensors/maze/LabyrinthSquare.qml (limited to 'examples/sensors/maze/LabyrinthSquare.qml') diff --git a/examples/sensors/maze/LabyrinthSquare.qml b/examples/sensors/maze/LabyrinthSquare.qml new file mode 100644 index 00000000..b82c8b2f --- /dev/null +++ b/examples/sensors/maze/LabyrinthSquare.qml @@ -0,0 +1,40 @@ +//Import the declarative plugins +import QtQuick 2.0 + +//Import the javascript functions for this game +import "lib.js" as Lib + +//Implementation of the Labyrinth square control. +Rectangle { + id: sq + x: 0 + y: 0 + width: Lib.cellDimension + height: Lib.cellDimension + color: "white" + property int val: 0 + property AnimatedImage picture: img + + //Dependend of its position and the labyrinth value a square can be the start, cheese, empty or a wall + AnimatedImage { + id: img + anchors.fill: parent + source: "" + } + + function updateImage() + { + if (sq.val == -1) + sq.picture.source = "images/start.png"; + else if (sq.val == 3) + sq.picture.source = "images/cheese.png"; + else if (sq.val == 4){ + sq.picture.source = "images/cheeseeating.gif"; + sq.picture.playing = true; + } + else if (sq.val == 1) + sq.picture.source = "images/01.png"; + else + sq.picture.source = "images/00.png"; + } +} -- cgit v1.2.3