Forums

OverviewV-Play 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
    V-Play 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
    V-Play 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
    V-Play 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.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support