MultiplayerDemoSimple
import Felgo 3.0
import QtQuick 2.0
import Qt.labs.settings 1.0
import QtQuick.Controls 1.1
GameWindow {
id: window
title: gameNetwork.user.deviceId + " - " + gameNetwork.user.name
Settings {
id: gameSettings
property alias counterAppInstances: gameNetwork.counterAppInstances
Component.onCompleted: {
console.log("settings loaded with counterAppInstances value:"+ counterAppInstances+ ", userName: " +gameNetwork.user.name)
gameSettings.counterAppInstances++
}
}
FelgoGameNetwork {
id: gameNetwork
gameId: 285
secret: "AmazinglySecureGameSecret"
multiplayerItem: multiplayer
user.deviceId: generateDeviceId()
clearAllUserDataAtStartup: true
property int counterAppInstances: 0
function generateDeviceId() {
if(system.isPlatform(System.IOS) || system.isPlatform(System.Android) || system.isPlatform(System.WindowsPhone)) {
return system.UDID
}
if(counterAppInstances > 0) {
return system.UDID+"_" + counterAppInstances % multiplayer.playerCount
} else {
return system.UDID
}
}
}
FelgoMultiplayer {
id: multiplayer
playerCount: 4
gameNetworkItem: gameNetwork
multiplayerView: gameScene.multiplayerView
startGameWhenReady: true
appKey: "dd7f1761-038c-4722-9f94-812d798cecfb"
}
GameScene {
id: gameScene
}
Component.onDestruction: {
gameSettings.counterAppInstances--