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

MultiplayerDemo

 import Felgo 3.0
 import QtQuick 2.0
 import "../common"

 // scene with the main menu
 SceneBase {
   id: menuScene

   // signal that indicate that other scenes should be displayed
   signal menuButtonPressed(string button)

   // background
   Rectangle {
     anchors.fill: gameWindowAnchorItem
     color: "white"
   }

   // the "logo"
   Text {
     id: logo
     anchors.horizontalCenter: gameWindowAnchorItem.horizontalCenter
     horizontalAlignment: Text.AlignHCenter
     y: 50
     font.pixelSize: 20
     color: "#f05352"
     text: "Felgo Multiplayer Demo"
   }

   // the name of the local player
   Text {
     anchors.top: logo.bottom
     anchors.topMargin: 10
     anchors.horizontalCenter: gameWindowAnchorItem.horizontalCenter
     horizontalAlignment: Text.AlignHCenter
     y: 10
     font.pixelSize: 16
     color: "black"
     text: "Player: " + gameNetwork.user.name
   }

   // start game buttons
   Column {
     anchors.centerIn: gameWindowAnchorItem
     anchors.verticalCenterOffset: 20
     spacing: 10

     MenuButton {
       text: "Quick Game"
       action: "quick"
     }

     MenuButton {
       text: "Matchmaking"
     }

     MenuButton {
       // for testing the friends status, user profile + flag in the leaderboard, when you select the "Game Network" button
       text: "Simulate Score +1"
       action: "increase_score"
     }
   }

   // community menu with invites, inbox, friends and game network
   Row{
     spacing: 10
     anchors.horizontalCenter: gameWindowAnchorItem.horizontalCenter
     anchors.bottom: gameWindowAnchorItem.bottom
     anchors.bottomMargin: 30

     MenuButton {
       text: "Invites"
       anchors.horizontalCenter: undefined
     }

     MenuButton {
       id: inboxButton
       text: "Inbox"
       anchors.horizontalCenter: undefined
     }

     MenuButton {
       text: "Friends"
       anchors.horizontalCenter: undefined
     }

     MenuButton {
       text: "Game Network"
       action: "gn"
       anchors.horizontalCenter: undefined
     }
   }

   // connection to the FelgoGameNetwork updates the inbox entries
   Connections{
     target: gameNetwork

     onInboxEntriesChanged:{
       var conv=gameNetwork.inboxEntries;
       var count=0;
       for(var i=0;i<conv.length;i++){
         count += conv[i].unread_count;
       }
       inboxButton.notification = count
     }
   }

   // search for new messages while this scene is visible
   onVisibleChanged: {
     if(visible){
       gameNetwork.api.inbox()
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded