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


OverviewFelgo 1 Support › Loading Scenes from GameWindow on Button press

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #4268



    I have a gamewindow, and in it I declared various Scenes.
    One Scene for menu, one Scene for Game, …

    What I want to do is display the Menu Scene by default, which shows various buttons.
    From these Buttons, I then what to load other Scenes to be displayed in the GameWindow.

    How do I do that?

    GameWindow {

    id: window

    MenuScene { ... }

    GameScene { ... }

    // and so on...


    MenuScene {

    id: mainMenu

    Button { ... } // should load the game scene
    Button { ... } // should load some other scene



    Felgo Team


    the easiest way to achieve this is by setting all scenes that you want not to display in the beginning to invisible, and change them to visible when the button is pressed (and set the active scene to invisible). You can achieve that by storing the current scene as a property variant. Another approach is using the states property in GameWindow: you can define in which states each of your scenes gets visible like the following code:

    GameWindow {
     id: gameWindow
     MenuScene {
      id: menuScene
      visible: true // should be visible from the beginning
      Button {
        onClicked: gameWindow.state = "game" // switch to GameScene
     GameScene {
      id: gameScene
      visible: false // should only be visible in state game
    // the default state is "", and it sets the MenuScene to visible and gameScene invisible
    states: [
        State {
          name: "game"
          PropertyChanges { target: gameScene; visible: true}
          PropertyChanges { target: menuScene; visible: false}
          StateChangeScript {
            script: {
              console.debug("entered state 'game'")
              console.debug("GameScene.visible:", gameScene.visible)
          }// end of StateChangeScript
        }// end of State game
    }// end of GameWindow


    With this approach, both scenes are loaded at runtime. You could also load them when they are first needed with the Loader element. For more details, please see the ChickenOutbreak and Squaby demos in the FelgoSDK in the Demos/Felgo SDK folder.

    Cheers, Chris

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded