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

Forums

OverviewFelgo 3 Support (Qt 5) › Multiple screens tutorial – Cannot assign to non-existent property "creditsPress

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #16115

    Alexander

    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

    #16116

    Alex
    Felgo Team

    Hi Alexander,

    please have a closer look at how you are using the signals. If the signal is named “creditsPressed”, the correct handler is called “onCreditsPressed”.

    Cheers,
    Alex

    #16117

    Alexander

    Hi Alex,

     

    Thx for the quick reply! With the renaming it worked now.

     

    Cheers,

    Alexander

Viewing 3 posts - 1 through 3 (of 3 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