SaveItDialog.qml Example File

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

 Item {
   anchors.fill: parent

   visible: false

   enabled: visible

   signal saveIt()
   signal killIt()
   signal activated()
   signal deactivated()

   property int yOffset: 60

   function setActive() {
     visible = true
     countdown.countdown = 5
     countdownTimer.restart()
     activated()
   }

   function setDissable() {
     visible = false
     deactivated()
   }

   Image {
     id: blackbg
     source: "../assets/blackbg.png"
     width: scene.gameWindowAnchorItem.width
     height: scene.gameWindowAnchorItem.height
     x: scene.gameWindowAnchorItem.x
     y: scene.gameWindowAnchorItem.y
   }

   MouseArea {
     anchors.fill: blackbg
     onClicked: {
       countdown.countdown--
       audioManager.play(audioManager.idTICK)
       if(countdown.countdown<=0) {
         countdownTimer.stop()
         killIt()
       }
     }
   }

   Item {
     id: descriptionItem
     anchors.horizontalCenter: parent.horizontalCenter
     y:80+yOffset
     //z:19
     width: signDescription.width
     height: signDescription.height

     Image {
       id: signDescription
       source: "../assets/sign.png"
       width: 150
       height: 120
       mirror: true
     }

     CoinDisplay {
       id: saveItButton
       y: 82
       anchors.left: parent.left
       anchors.leftMargin: 20
       rotation: 2
       customCoins: store.saveit.balance
       displayCustomCoins: true
     }

     MenuText {
       y: 82
       anchors.left: saveItButton.right
       anchors.leftMargin: 10
       rotation: 2
       text: qsTr("Call Angel")
       font.pixelSize: 22
     }

     MouseArea {
       anchors.fill: parent
       onClicked: {
         audioManager.play(audioManager.idMENUCLICK)
         playNBuy()
         parent.scale = 1.0
       }
       onPressed: {
         parent.scale = 0.85
       }
       onReleased: {
         parent.scale = 1.0
       }
       onCanceled: {
         parent.scale = 1.0
       }
     }
   }

   Image {
     id: signCountdown
     source: "../assets/sign.png"
     anchors.horizontalCenter: parent.horizontalCenter
     y: -118+yOffset
     width: 300
     height: 270
     //z: 20
   }

   MenuText {
     id: countdown
     anchors.top: signCountdown.top
     anchors.topMargin: 167
     anchors.horizontalCenter: signCountdown.horizontalCenter
     property int countdown: 0
     text: " ( "+countdown.countdown+" ) "
     font.pixelSize: 55
     rotation: -1.5
   }

   MenuText {
     id: headline
     anchors.bottom: signCountdown.bottom
     anchors.bottomMargin: 20
     anchors.horizontalCenter: signCountdown.horizontalCenter
     rotation: -1.5
     text: qsTr("Time to rescue hen")
     font.pixelSize: 22
   }

   Timer {
     id: countdownTimer
     interval: 1000
     repeat: true
     onTriggered: {
       countdown.countdown--
       audioManager.play(audioManager.idTICK)
       if(countdown.countdown<=0) {
         stop()
         killIt()
       }
     }
   }

   CurrencyPackPage {
     id: currencyPackPage
     opacity: 0
     isMoney: false
     z:22

     onBoughtPack: {
       countdownTimer.start()
     }

     onClosed: {
       countdownTimer.start()
     }
   }

   function playNBuy() {
     if(store.saveit.balance > 0) {
       store.takeItem("currency_saveit_id",1)
       countdownTimer.stop()
       saveIt()
       deactivated()
     } else {
       countdownTimer.stop()
       currencyPackPage.opacity = 1
     }
   }
 }

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