ScoreTest.qml Example File

examples/gamenetwork/GameNetworkTest/qml/ScoreTest.qml
 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"
   }
  }// Column
 }

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