Squaby Demo
import QtQuick 2.0
import Felgo 4.0
Item {
id: startClock
property bool running: false
property alias waitsForStart: background.visible
property bool enabled: true
function restart() {
background.visible = 1.0
squabyCreator.reset()
}
function start() {
if(running) {
console.debug("ERROR: StartClock was already running, but start() was called again - this is a programmer error and should not happen")
return
}
running = true
}
function pause() {
running = false
if(squabyCreator.enabled) {
squabyCreator.pause()
}
}
function stop() {
running = false
}
onEnabledChanged: {
if(enabled && !running) {
running = true;
}
if(!enabled && running)
running = false;
}
onRunningChanged: {
if(running && !enabled) {
console.debug("Start Clock: running was true, but enabled was false, thus change running to false as well");
running = false;
}
}
Rectangle {
id: background
x: scene.gameWindowAnchorItem.x
y: scene.gameWindowAnchorItem.y
width: scene.gameWindowAnchorItem.width
height: scene.gameWindowAnchorItem.height
opacity: 0.2
MouseArea {
anchors.fill: parent
onClicked: {
stop()
startClock.triggerClock()
}
}
color: "black"
visible: false
}
Text {
id: startGameCountdown
visible: background.visible
color: "white"
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenterOffset: -hud.height/2
text: qsTr("Tap to Start") + (levelEditor.currentLevelNameString.toLowerCase().search("level")<0 ? qsTr(" Level") : "")
font.family: jellyFont.name
font.pixelSize: 42
}
Text {
visible: background.visible
color: "white"
anchors.top: startGameCountdown.bottom
anchors.topMargin: 2
anchors.horizontalCenter: parent.horizontalCenter
text: levelEditor.currentLevelNameString
font.family: jellyFont.name
font.pixelSize: 42
}
function triggerClock() {
background.visible = false
if(tutorials.running && !scene.cameFromLevelEditing) {
tutorials.nextAction("startClock","startGame")
} else {
squabyCreator.restart()