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

GameNetworkExample

 import Felgo 3.0
 import QtQuick 2.0

 TestBase {

   property bool textInputForLeaderboardInput: false

  Column {
   SimpleButton {
     text: "Report Higher Score: " + (highscore+1).toString()
     onClicked: {
       gameNetwork.reportScore(highscore+1)
       // the highscore is no modified by the GameNetwork!
       // until the reading of the highscore is implemented increase the score here
       //highscore++
     }
   }

   SimpleButton {
     text: "Get User Score"
     onClicked: {
       gameNetwork.api.getUserScore()
     }
   }

   SimpleButton {
     text: "Get Leaderboard Scores"
     onClicked: {
       gameNetwork.api.getLeaderboardScores()
     }
   }

   SimpleButton {
     text: "Change Leaderboard"
     onClicked: {
       textInputForLeaderboardInput = true
       nativeUtils.displayTextInput("Enter Leaderboard", "", "", gameNetwork.currentActiveLeaderboard)

     }
   }

   Connections {
     target: nativeUtils
     onTextInputFinished: {

       if(textInputForLeaderboardInput && accepted) {
         gameNetwork.currentActiveLeaderboard = enteredText
       }
       textInputForLeaderboardInput = false
     }
   }

   SimpleButton {
     text: "Show Leaderboard"
     onClicked: {
       gameNetwork.showLeaderboard()
     }
   }

   SimpleButton {
     text: "Report Slider Score " + Math.round(scoreSlider.value)
     onClicked: {
       gameNetwork.reportScore(Math.round(scoreSlider.value))
     }
   }

   SimpleButton {
     text: "Report Relative Slider Score " + Math.round(scoreSlider.value)
     onClicked: {
       gameNetwork.reportRelativeScore(Math.round(scoreSlider.value))
     }
   }

   GameSlider {
     id: scoreSlider
     minimumValue: -100
     maximumValue: 100
     value: 10
     width: 200
     height: 20
   }

   Text {
     text: "highscore: " + highscore + "\ncurrentLB: " + gameNetwork.currentActiveLeaderboard
     color: "white"
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded