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

Forums

OverviewFelgo 1 Support › Refresh Scene / Refresh Flickable

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #4327

    phil.jahoda

    Simple question:

    Is it possible to refresh a certain Scene that I create in my GameWindow?

    For example I create two Scenes in my GameWindow at app start. The content displayed in both Scenes is defined by variables that can change at runtime.
    By setting opacity, I display Scene A, and in it, I change values that the content of Scene B is dependant on.
    If I then switch to Scene B by setting A.opacity to 0 and B.opacity to 1, the content of Scene B remains unchanged.
    How can I refresh Scene B or make it reload its content?

    As Scene B’s content is a flickable, it would also be possible to only refresh the flickable, but I dont know how.

    #4329

    Christian
    Felgo Team

    Hi,

    could you please post source code of the relevant code part?

    Cheers, Chris

    #4331

    phil.jahoda

     

    Walkthrough:

    – start the app

    – SceneA is displayed and shows a score of 10

    – we press the “entersceneBbutton” and SceneB is displayed

    – we press the “changescorebutton” and change the window value to 20, and then the “backbutton”

    – now, SceneA is displayed again, but my problem is, that the text still displays 10

    – displaying the individual scenes is done by changing opacity, just like in Squaby

     

    Example code:

    main.qml

    GameWindow {

    id: window

    property int score: 10

    state: “sceneA”

    SceneA {
    id: sceneA
    }
    SceneB {
    id: sceneB
    }

    states: [
    State {
    name: “sceneA”
    PropertyChanges { target: sceneA; opacity: 1 }
    PropertyChanges { target: sceneB; opacity: 0 }
    },
    State {
    name: “sceneB”
    PropertyChanges { target: sceneB; opacity: 1 }
    PropertyChanges { target: sceneA; opacity: 0 }
    }
    ]

    }  // gamewindow end

    SceneA.qml

    SceneA {

    Text {
    id: scoredisplay
    text: window.score
    }
    Button {
    id: entersceneBbutton
    onClicked: window.state = “sceneB”
    }
    }

    SceneB.qml

    SceneB {

    Button {
    id: changebutton
    onClicked: window.score = 20;
    }
    Button {
    id: backbutton
    onClicked: window.state = “sceneA”
    }
    }

     

    #4333

    Christian
    Felgo Team

    Hi,

    you are putting 2 buttons on top of each other, thus only the above button gets the clicked signal, which is the one to switch to sceneA.

    Cheers, Chris

    #4334

    phil.jahoda

    Do you mean the 2 Buttons in SceneB?
    How can they be on top of each other?
    Those are just 2 Buttons right beside each other. I also made a console.debug output, which indicates that both buttons are pressed.

    #4335

    Christian
    Felgo Team

    In the source code you posted, those 2 buttons are on the same position on top of each other. I tried your setting and modified it so they are below each other, and the text modification works without any issues:

    import VPlay 1.0
    import QtQuick 1.1
    
    GameWindow {
    
      id: window
    
      property int score: 10
    
      state: "sceneA"
    
    
      Scene {
        id: sceneA
    
        Text {
          id: scoredisplay
          text: window.score
          color: "red"
          anchors.centerIn: parent
        }
        SimpleButton {
          id: entersceneBbutton
          text: "Switch to stateB"
          onClicked: window.state = "sceneB"
        }
    
      }
    
      Scene {
        id: sceneB
        Column {
          Button {
            id: changebutton
            text: "switch score to 20"
            onClicked: window.score = 20;
          }
          SimpleButton {
            id: backbutton
            text: "Switch to stateA"
            onClicked: window.state = "sceneA"
          }
        }
      }
    
      states: [
        State {
          name: "sceneA"
          PropertyChanges { target: sceneA; opacity: 1 }
          PropertyChanges { target: sceneB; opacity: 0 }
        },
        State {
          name: "sceneB"
          PropertyChanges { target: sceneB; opacity: 1 }
          PropertyChanges { target: sceneA; opacity: 0 }
        }
      ]
    
    }  // gamewindow end
    
    

    Side note: please use the Code button to insert QML code.

    Cheers, Chris

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