Stack With Friends Demo
import QtQuick 2.0
import Felgo 3.0
Item {
opacity: 0
width: textItem.width
Text {
id: textItem
color: "#ffffff"
font.family: fontHUD.name
font.pixelSize: 14
text: "1 Free Credit! Come back in 24h to get another!"
}
MultiResolutionImage {
source: "../../assets/img/star.png"
anchors.right: textItem.left
anchors.rightMargin: 5
anchors.verticalCenter: textItem.verticalCenter
}
MultiResolutionImage {
source: "../../assets/img/star.png"
anchors.left: textItem.right
anchors.verticalCenter: textItem.verticalCenter
}
function giveBonusAfterDelay() {
flurry.logEvent("Game.DailyBonusGranted")
levelStore.giveCurrency(1)
opacity = 1
displayTimer.start()
}
function checkForDailyBonus() {
var today = new Date()
var todayTruncated = new Date(today.getTime()-today.getHours()*3600000-today.getMinutes()*60000-today.getSeconds()*1000-today.getMilliseconds())
console.debug("Today truncated is " + todayTruncated.getTime())
var storedLastLoginMS = settings.getValue("lastLogin")
console.debug("Read from database " + storedLastLoginMS)
if(!storedLastLoginMS)
settings.setValue("lastLogin",todayTruncated.getTime())
else {
if(todayTruncated.getTime() > storedLastLoginMS) {
console.debug("Last login was a day ago, give player bonus")
settings.setValue("lastLogin",todayTruncated.getTime())
giveBonusDelay.start()
}
}
}
Timer {
id: displayTimer
interval: 5000
running: false
onTriggered: parent.opacity = 0
}
Timer {
id: giveBonusDelay
interval: 1000
running: false
onTriggered: giveBonusAfterDelay()
}
Behavior on opacity {