Forums

OverviewV-Play 1 Support › Refresh Flickable

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #4373

    phil.jahoda

    In a Scene, we are using a Flickable that is displaying a Colum with TextViews (TextViews are in Repeater).

    The TextViews display data that is read from the settings when the Flickable is first created.

     

    WIthin that Scene, the users actions can cause a change in the values stored in the settings. In that case, I want to refresh the repeater as well, how is that possible?

    #4374

    Christian
    V-Play Team

    Hi,

    could you post the relevant source code please?

    Cheers, Chris

    #4375

    phil.jahoda

    Whenever I say player.loadHighscore() i access the settings.

     

    import VPlay 1.0
    import QtQuick 1.1
    
    Scene {
    
      Flickable {
    
        id: flickable
        x: -200
        y: 20
    
        width: parent.width / 2
        height: parent.height
    
        contentWidth: column.width
        contentHeight: column.height
        flickableDirection: Flickable.VerticalFlick
    
        // The duration of the slide animation for this button
        property int slideDuration: 800
    
        Column {
    
          id: column
          spacing: 5
          anchors.centerIn: parent
    
          Repeater {
            id: repeater
            model: window.numberoflevels
    
            MenuButton {
              text: getHighScoreText(modelData + 1);
              source: "img/cloud.png"
                      textSize: 10
              fontBold: true
            }
          }
        }
    
        Behavior on x {
          SmoothedAnimation { duration: 800; easing.type: Easing.InOutQuad }
        }
    
        function slideIn() {
          x = parent.width - flickable.width
        }
    
        function slideOut() {
          x = -200
        }
      }
    
      function getHighScoreText(modelData) {
        return "Level " + (modelData) + " – Score:" + " " + player.loadHighScore("0"+(modelData));
        //+ “, Remaining Arrows: ” + player.loadRemArrows(“0″+(modelData));
      }
    
      // THE BELOW CODE IS NOT WORKING
      function update() {
    
        for(var i = 0; i < window.numberoflevels; i++) {
    
          repeater.childAt(i).text = getHighScoreText(i+1);
        }
      }
    
      // an so on…
    }
    

     

    #4377

    Christian
    V-Play Team

    Hi,

    instead of modifying the modelData property, which is read-only I think, you could change your code so it works correctly with the Repeater element. As the doc of Repeater element is saying, you could change your model to an array of strings or integer values, to something like [“123”, “456”, “789”] where each of the elments holds the scores for a level.

    Note: please use the Code button, so the code is easier to read and correctly formatted with indentation.

    Cheers, Chris

    #4382

    phil.jahoda

    Thank you for your response, I will try that.

    PS: I am always using the “Code” button, and then I strg+v my code. Unfortunately it doesnt seem to work or I dont see what I am doing wrong :)

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