DailyBonus.qml Example File

demos/ChickenOutbreak2/qml/DailyBonus.qml
 import QtQuick 2.0

 Item {
   width: 180
   height: 25
   opacity: 0

   property int count: 10
   property int itemType: 0

   Image {
     source: "../assets/button.png"
     width: 180
     height: 25
   }

   Image {
     source: "../assets/coin_single.png"
     width: 15.25
     height: 20
     x: 15
     y: 2
     visible: itemType === 0
   }

   Image {
     source: "../assets/parachute.png"
     width: 20
     height: 20
     x: 15
     y: 2
     visible: itemType === 1
   }

   Image {
     source: "../assets/teleport.png"
     width: 20
     height: 20
     x: 15
     y: 2
     visible: itemType === 2
   }

   Text {
     color: "#f1ed00"
     font.family: fontHUD.name
     font.pixelSize: 20
     x: 45
     text: qsTr("plus ") + count + qsTr(" daily bonus")
   }

   function giveBonus() {
     giveBonusDelay.start()
   }

   function giveBonusAfterDelay() {
     var item = Math.random()
     if(item < 0.44) {
       count = 1
       itemType = 1
       parachuteCount++
       audioManager.play(audioManager.idPARACHUTE)
     } else if(item >0.44 && item < 0.77) {
       count = 1
       itemType = 2
       teleportCount++
       audioManager.play(audioManager.idTELEPORT)
     } else {
       count = 10
       itemType = 0
       store.giveItem("currency_money_id",count)
       audioManager.play(audioManager.idPLING)
     }
     opacity = 1
     displayTimer.start()
   }

   Timer {
     id: displayTimer
     interval: 5000
     running: false
     onTriggered: parent.opacity = 0
   }

   Timer {
     id: giveBonusDelay
     interval: 1000
     running: false
     onTriggered: giveBonusAfterDelay()
   }

   Behavior on opacity {
     NumberAnimation{duration: 500}
   }

   MouseArea {
     anchors.fill: parent
     onClicked: {
        parent.opacity = 0
     }
   }
 }

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