Juicy Squash - Match-3 Game
import Felgo 4.0
import QtQuick 2.0
import "scenes"
GameWindow {
id: gameWindow
screenWidth: 640
screenHeight: 960
FontLoader {
id: gameFont
source: Qt.resolvedUrl("../assets/fonts/akaDylan Plain.ttf")
}
Rectangle {
id: loadScreen
width: gameWindow.width
height: gameWindow.height
color: "white"
z: 1
opacity: 0
enabled: opacity == 1 ? true : false
visible: opacity > 0 ? true : false
signal fullyVisible()
Text {
font.family: gameFont.name
font.pixelSize: gameWindow.width / 640 * 24
color: "red"
text: "Loading ..."
anchors.centerIn: parent
}
Behavior on opacity {
PropertyAnimation {
duration: 300
onRunningChanged: {
if(!running && opacity == 1)
loadScreen.fullyVisible()
}
}
}
}
SplashScreenScene {
id: splashScene
onSplashScreenFinished: gameWindow.state = "game"
}
Loader {
id: gameSceneLoader
onLoaded: loadScreen.opacity = 0
}
state: "splash"
states: [
State {
name: "splash"
PropertyChanges {target: splashScene; opacity: 1}
PropertyChanges {target: gameWindow; activeScene: splashScene}
},
State {
name: "game"
StateChangeScript {
script: {
showGameScene()
}
}
}
]
function showGameScene() {
if(gameSceneLoader.item === null) {
gameSceneLoader.loaded.connect(showGameScene)
loadGameScene()
return
}
gameWindow.activeScene = gameSceneLoader.item
gameSceneLoader.item.opacity = 1
}
function loadGameScene() {
loadScreen.opacity = 1
loadScreen.fullyVisible.connect(fetchAndInitializeGameScene)
}
function fetchAndInitializeGameScene() {
gameSceneLoader.source = "scenes/GameScene.qml"
loadScreen.fullyVisible.disconnect(fetchAndInitializeGameScene)
}
function onBackButtonPressed() {