Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Multi-Scene-Multi-Level Demo

 import Felgo 4.0
 import QtQuick 2.0
 import "scenes"

 GameWindow {
   id: window
   screenWidth: 960
   screenHeight: 640

   // You get free licenseKeys from https://felgo.com/licenseKey
   // With a licenseKey you can:
   //  * Publish your games & apps for the app stores
   //  * Remove the Felgo Splash Screen or set a custom one (available with the Pro Licenses)
   //  * Add plugins to monetize, analyze & improve your apps (available with the Pro Licenses)
   //licenseKey: "<generate one from https://felgo.com/licenseKey>"

   // create and remove entities at runtime
   EntityManager {
     id: entityManager

   // menu scene
   MenuScene {
     id: menuScene
     // listen to the button signals of the scene and change the state according to it
     onSelectLevelPressed: window.state = "selectLevel"
     onCreditsPressed: window.state = "credits"
     // the menu scene is our start scene, so if back is pressed there we ask the user if he wants to quit the application
     onBackButtonPressed: {
       NativeUtils.displayMessageBox(qsTr("Really quit the game?"), "", 2);
     // listen to the return value of the MessageBox
     Connections {
       target: NativeUtils
       onMessageBoxFinished: {
         // only quit, if the activeScene is menuScene - the messageBox might also get opened from other scenes in your code
         if(accepted && window.activeScene === menuScene)

   // scene for selecting levels
   SelectLevelScene {
     id: selectLevelScene
     onLevelPressed: selectedLevel => {
       window.state = "game"

     onBackButtonPressed: window.state = "menu"

   // credits scene
   CreditsScene {
     id: creditsScene
     onBackButtonPressed: window.state = "menu"

   // game scene to play a level
   GameScene {
     id: gameScene
     onBackButtonPressed: window.state = "selectLevel"

   // menuScene is our first scene, so set the state to menu initially
   state: "menu"
   activeScene: menuScene

   // state machine, takes care reversing the PropertyChanges when changing the state, like changing the opacity back to 0
   states: [
     State {
       name: "menu"
       PropertyChanges {target: menuScene; opacity: 1}
       PropertyChanges {target: window; activeScene: menuScene}
     State {
       name: "selectLevel"
       PropertyChanges {target: selectLevelScene; opacity: 1}
       PropertyChanges {target: window; activeScene: selectLevelScene}
     State {
       name: "credits"
       PropertyChanges {target: creditsScene; opacity: 1}
       PropertyChanges {target: window; activeScene: creditsScene}
     State {
       name: "game"
       PropertyChanges {target: gameScene; opacity: 1}
       PropertyChanges {target: window; activeScene: gameScene}
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded