Hi,
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