Hi!
I am trying to do the multiple screens tutorial but I am stuck at the point where the signals of the scenes are used to switch between them.
This is my Main.qml
import Felgo 3.0
import QtQuick 2.0
import "scenes"
GameWindow {
id: gameWindow
screenWidth: 960
screenHeight: 640
EntityManager {
id: entityManager
}
// menu scene
MenuScene {
id: menuScene
// listen to the button signals of the scene and change the state according to it
startSimulationPressed: gameWindow.state = "game"
creditsPressed: gameWindow.state = "credits"
}
// game scene
GameScene {
id: gameScene
//onMenuScenePressed: gameWindow.state = "menu"
}
// credits scene
CreditsScene {
id: creditsScene
}
// default state is menu -> default scene is menuScene
state: "menu"
activeScene: menuScene
// state machine, takes care of reversing the PropertyChanges when changing the state. e.g. it changes the opacity back to 0
states: [
State {
name: "menu"
PropertyChanges {target: menuScene; opacity: 1}
PropertyChanges {target: gameWindow; activeScene: menuScene}
},
State {
name: "game"
PropertyChanges {target: golScene; opacity: 1}
PropertyChanges {target: gameWindow; activeScene: gameScene}
},
State {
name: "credits"
PropertyChanges {target: creditsScene; opacity: 1}
PropertyChanges {target: gameWindow; activeScene: creditsScene}
}
]
}
And this my MenuScene.qml
import Felgo 3.0
import QtQuick 2.0
import "../entities"
// The Menu Scene
SceneBase {
id: menuScene
// signal indicating that the gameScene should be displayed
signal startSimulationPressed
// signal indicating that the creditsScene should be displayed
signal creditsPressed
// background
Rectangle {
anchors.fill: parent.gameWindowAnchorItem
color: "#47688e"
}
// the "logo"
Text {
anchors.horizontalCenter: parent.horizontalCenter
y: 30
font.pixelSize: 30
color: "#e9e9e9"
text: "MultiSceneMultiLevel"
}
// menu
Column {
anchors.centerIn: parent
spacing: 10
MenuButton {
text: "Start Simulation"
onClicked: startSimulationPressed()
}
MenuButton {
text: "Credits"
onClicked: creditsPressed()
}
}
}
So with this setup, I always get the error “…qml/Main.qml:21 Cannot assign to non-existent property “creditsPressed”. The weird thing is, before I got the exact same thing for the other signal. I just rearranged some things in both files and now I get the other error.
After trying out several changes and looking up the tutorial up and down I cannot find any explanation for this behavior and would appreciate some help for that.
Thx in advance!
Alexander