ChickenOutbreak2Main.qml Example File

demos/ChickenOutbreak2/qml/ChickenOutbreak2Main.qml
 import QtQuick 2.0
 import Felgo 3.0

 GameWindow {
   id: window
   // depending on which window size is defined as start resolution here, the corresponding image sizes get loaded here! so for testing hd2 images, at least use factor 3.5
   // the window size can be changed at runtime by pressing the keys 1-6 (see GameWindow.qml)
   screenWidth: 640 // for testing on desktop with the highest res, use *1.5 so the -hd2 textures are used
   screenHeight: 960

   // You get free licenseKeys from https://felgo.com/licenseKey
   // With a licenseKey you can:
   //  * Publish your games & apps for the app stores
   //  * Remove the Felgo Splash Screen or set a custom one (available with the Pro Licenses)
   //  * Add plugins to monetize, analyze & improve your apps (available with the Pro Licenses)
   //licenseKey: "<generate one from https://felgo.com/licenseKey>"

   property bool developerBuild: !system.publishBuild
   property int maximumHighscore: 0

   onMaximumHighscoreChanged: {
     if(implLoader.item) implLoader.item.maximumHighscoreChanged()
   }

   AudioManager {
     id: audioManager
   }

   // Custom font loading of ttf fonts
   FontLoader {
     id: fontHUD
     source: "fonts/rodeo.ttf"
   }

   // Flurry is only available on iOS and Android
   Flurry {
     id: flurry
     // this is the app key for the ChickenOutbreak2-SDK-Demo, be sure to get one for your own application if you want to use Flurry
     apiKey: ""
   }

   ChartboostView {
     id: chartboostView
   }

   // be sure to enable GameCenter for your application (developer.apple.com)
 //  GameCenter {
 //    id: gameCenter

 //    // Use highscore from GameCenter if it is higher than our local one
 //    onAuthenticatedChanged: {
 //      if (authenticated === true) {
 //        // For debugging only
 //        // resetAchievements();

 //        var gameCenterScore = getGameCenterScore();
 //        if (gameCenterScore > maximumHighscore)
 //          maximumHighscore = gameCenterScore;
 //      }
 //    }
 //  }

   Facebook {
     // the user will automatically connect with facebook, once "connect" is pressed in the UserTest
     id: facebook

     // this is the dev version of the fb app, "Chicken Outbreak 2 Dev"
     appId: "583338428422091"

     readPermissions: ["email", "read_friendlists"]
     publishPermissions: ["publish_actions"]
   }

   Component.onCompleted: {
     // disable log output in release mode on buildserver
     if(!developerBuild) {
       system.logOutputEnabled = false
     }

     if(!system.isPlatform(System.IOS)) {
       splashLoader.source = "SplashScreen.qml"
     } else {
       implLoader.source = "ChickenOutbreak2MainItem.qml"
     }
   }

   // the initial state should be the main state
   state: "main"

   Timer {
       id: splashScreenOff
       interval: 1000
       onTriggered: {
         if(splashLoader.item) {
           splashLoader.item.exitScene()
         }
       }
     }
     Timer {
       id: startLoading
       interval: 1000
       onTriggered: {
         // load actual game
         implLoader.source = "ChickenOutbreak2MainItem.qml"
       }
     }

     Connections {
       target: splashLoader.item ? splashLoader.item : null
       onLoadingFinished: {
         if(implLoader.item) {
           implLoader.item.activateMain()
         }
         // unload splashscreen
         splashLoader.source = ""
       }
     }

     Loader {
       id: splashLoader
       onLoaded: {
         if(item) {
           item.enterScene()
         }
         startLoading.start()
       }
     }

     Loader {
       id: implLoader
       onLoaded: {
         if(item) {
           splashScreenOff.start()

           if(implLoader.item && system.isPlatform(System.IOS)) {
             implLoader.item.activateMain()
           }
         }
       }
     }

     onStateChanged: {
       if(implLoader.item) implLoader.item.state = state
     }

     onApplicationPaused: {
       if(implLoader.item) implLoader.item.pauseGame()
     }
 }

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