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

ChickenOutbreak2 Demo

 import QtQuick 2.0
 import Felgo 3.0

 Item {
   id: currencyPackPage
   width: scene.gameWindowAnchorItem.width
   height: scene.gameWindowAnchorItem.height
   x: scene.gameWindowAnchorItem.x
   y: scene.gameWindowAnchorItem.y

   signal boughtPack
   signal closed

   visible: opacity > 0
   enabled: visible

   onBoughtPack: {
     opacity = 0
   }
   onClosed: {
     audioManager.play(audioManager.idMENUCLICK)
     opacity = 0
   }

   property bool isMoney: true

   Rectangle {
     anchors.fill: parent
     color: "black"
     opacity: 0.9
   }

   // if the player presses the overlay, hide it
   /*MouseArea {
     anchors.fill: parent
     onClicked: {
       closed()
     }
   }*/

   Text {
     text: isMoney ? qsTr("Buy coins to get ingame items!") : qsTr("Buy Angels to save your chicken from death!")
     anchors.horizontalCenter: parent.horizontalCenter
     anchors.bottom: currencyIcon.top
     anchors.bottomMargin: 10
     color: "white"
   }

   CoinDisplay {
     id: currencyIcon
     customCoins: isMoney ? 0 : store.saveit.balance
     displayCustomCoins: !isMoney
     displayBonusCoins: false

     anchors.horizontalCenter: parent.horizontalCenter
     anchors.bottom: contentColumn.top
     anchors.bottomMargin: 10
     color: "white"
   }

   Column {
     id: contentColumn
     anchors.centerIn: parent
     width: parent.width*0.8
     spacing: 10
     CurrencyPackageElement {
       source: currencyPackPage.isMoney ? "../assets/buy_currency_1.png" : "../assets/buy_saveit_1.png"
       isMoney: currencyPackPage.isMoney
       description: isMoney ? qsTr("Buy 100 Coins") : qsTr("Buy 1 Angel")
       message: isMoney ? qsTr("Buy power ups with coins") : qsTr("Buy angel to save one chicken")
       packID: isMoney ? store.money1Pack.itemId : store.saveit1Pack.itemId
       onBought: {
         connectingScreen.visible = true
       }
     }
     CurrencyPackageElement {
       source: isMoney ? "../assets/buy_currency_2.png" : "../assets/buy_saveit_2.png"
       isMoney: currencyPackPage.isMoney
       description: isMoney ? qsTr("Buy 300 Coins") : qsTr("Buy 3 Angels")
       message: isMoney ? qsTr("Save 33 percent") : qsTr("Save 33 percent")
       packID: isMoney ? store.money2Pack.itemId : store.saveit2Pack.itemId
       onBought:  {
         connectingScreen.visible = true
       }
     }
     CurrencyPackageElement {
       source: isMoney ? "../assets/buy_currency_3.png" : "../assets/buy_saveit_3.png"
       isMoney: currencyPackPage.isMoney
       description: isMoney ? qsTr("Buy 800 Coins") : qsTr("Buy 10 Angels")
       message: isMoney ? qsTr("Save 50 percent") : qsTr("Save 60 percent")
       packID: isMoney ? store.money3Pack.itemId : store.saveit3Pack.itemId
       onBought:  {
         connectingScreen.visible = true
       }
     }
     CurrencyPackageElement {
       source: isMoney ? "../assets/buy_currency_4.png" : "../assets/buy_saveit_4.png"
       isMoney: currencyPackPage.isMoney
       description: isMoney ? qsTr("Buy 1400 Coins") : qsTr("Buy 20 Angels")
       message: isMoney ? qsTr("Save 57 percent") : qsTr("Save 70 percent")
       packID: isMoney ? store.money4Pack.itemId : store.saveit4Pack.itemId
       onBought:  {
         connectingScreen.visible = true
       }
     }
   }

   // display a dummy close sign, just to give the player a hint that he can close the achievement by pressing
   /*Text {
     text: "X"
     color: "#444444"
     font.pixelSize: 30
     anchors.right: parent.right
     font.family: fontHUD.name
     anchors.rightMargin: 8
   }*/

   MenuButton {
     anchors.horizontalCenter: parent.horizontalCenter
     anchors.bottom: parent.bottom
     anchors.bottomMargin: 20

     text: qsTr("Back")

     onClicked: closed()
   }
   // make opacity changes smooth
   Behavior on opacity {
     NumberAnimation { duration: 150}
   }

   Connections {
     target: currencyPackPage.opacity > 0 ? store : null

     onInsufficientFundsError: {
       connectingScreen.visible = false
     }
     onItemNotFoundError:  {
       connectingScreen.visible = false
     }
     onItemPurchased: {
       connectingScreen.visible = false
     }

     onStorePurchaseCancelled: {
       connectingScreen.visible = false
     }

     onStorePurchased: {
       connectingScreen.visible = false
       boughtPack()
     }
   }

   //hide this because signals from store are not emitted correctly
   Rectangle {
     id: connectingScreen
     visible: false
     anchors.fill: parent
     color: "black"
     Text {
       anchors.centerIn: parent
       text: "Connecting..."
       color: "#444444"
       font.pixelSize: 30
       font.family: fontHUD.name
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded