Flappy Bird Game
import Felgo 4.0
import QtQuick 2.0
import "scenes"
import "common"
Item {
id: mainItem
property alias audioManager: audioManager
property alias entityManager: entityManager
property alias gameNetwork: felgoGameNetworkScene.gameNetwork
property int highscore: gameNetwork.userHighscoreForCurrentActiveLeaderboard
property int coins
AudioManager {
id: audioManager
}
MenuScene {
id: menuScene
onGamePressed: {
mainItem.state = "game"
}
onNetworkPressed: {
felgoGameNetworkScene.initialStateBeforeShow = "menu"
mainItem.state = "gameNetwork"
}
onBackButtonPressed: {
NativeUtils.displayMessageBox("Really quit the game?", "", 2);
}
Connections {
target: window.activeScene === menuScene ? NativeUtils : null
function onMessageBoxFinished(accepted) {
if(accepted) {
Qt.quit()
}
}
}
}
GameScene {
id: gameScene
onMenuPressed: {
mainItem.state = "menu"
}
onNetworkPressed: {
felgoGameNetworkScene.initialStateBeforeShow = "game"
mainItem.state = "gameNetwork"
}
onUseCoinsPressed: {
}
}
FelgoGameNetworkScene {
id: felgoGameNetworkScene
onBackButtonPressed: {
mainItem.state = felgoGameNetworkScene.initialStateBeforeShow
}
}
EntityManager {
id: entityManager
entityContainer: gameScene.entityContainer
}
state: "menu"
states: [
State {
name: "menu"
PropertyChanges {target: menuScene; opacity: 1}
PropertyChanges {target: window; activeScene: menuScene}
StateChangeScript {
script: {
audioManager.play(audioManager.idSWOOSHING)
}
}
},
State {
name: "gameNetwork"
PropertyChanges {target: felgoGameNetworkScene; opacity: 1}
PropertyChanges {target: window; activeScene: felgoGameNetworkScene}
},
State {
name: "game"
PropertyChanges {target: gameScene; opacity: 1}
PropertyChanges {target: window; activeScene: gameScene}
StateChangeScript {
script: {
gameScene.enterScene()
audioManager.play(audioManager.idSWOOSHING)
}
}