ChickenOutbreak2 Demo
import QtQuick 2.0
Item {
width: 180
height: 25
opacity: 0
property int count: 1
Image {
source: Qt.resolvedUrl("../assets/button.png")
width: 180
height: 25
}
Image {
source: Qt.resolvedUrl("../assets/coin_single.png")
width: 15.25
height: 20
x: 15
y: 2
}
Text {
color: "#f1ed00"
font.family: fontHUD.name
font.pixelSize: 20
x: 45
text: qsTr("plus ") + count + qsTr(" hourly bonus")
}
function isBonusTime() {
var today = new Date()
var storedLastHourlyMS = settings.getValue("lastHourlyBonus")
if(!storedLastHourlyMS) {
return true
} else {
if(today.getHours() !== storedLastHourlyMS) {
return true
}
}
return false
}
function giveBonus() {
giveBonusDelay.start()
}
function giveBonusAfterDelay() {
audioManager.play(audioManager.idCORN)
audioManager.play(audioManager.idPLING)
var today = new Date()
settings.setValue("lastHourlyBonus",today.getHours())
store.giveItem("currency_money_id",count)
opacity = 1
displayTimer.start()
}
Timer {
id: displayTimer
interval: 5000
running: false
onTriggered: parent.opacity = 0
}
Timer {
id: giveBonusDelay
interval: 100
running: false
onTriggered: giveBonusAfterDelay()
}
Behavior on opacity {
NumberAnimation{duration: 500}
}
MouseArea {
anchors.fill: parent
onClicked: {
parent.opacity = 0