Squaby Demo
import QtQuick 2.0
import Felgo 4.0
Item {
id: towerBaseSprite
property int rotationOffset: -90
rotation: -parent.rotation+rotationOffset
property string spriteSheetSource
property int frameElement: 1
MultiResolutionImage {
source: towerBaseSprite.spriteSheetSource
anchors.centerIn: parent
}
function setTowerImageFromEvent(event) {
var rangeUpgrade;
var shootDelayUpgrade;
for(var i=0;i<event.upgrades.length;i++) {
var upgrade = event.upgrades[i];
if(upgrade.type === "range")
rangeUpgrade = upgrade;
else if(upgrade.type === "shootDelay" || upgrade.type === "damagePerSecond")
shootDelayUpgrade = upgrade;
}
if(!rangeUpgrade || !shootDelayUpgrade) {
console.log("WARNING: one of the necessary upgrades range or shootDelay not found, this should never happen!");
return;
}
if(shootDelayUpgrade.currentPlayerUpgradeLevel === 1 && rangeUpgrade.currentPlayerUpgradeLevel === 1) {
frameElement = 4;
} else if(rangeUpgrade.currentPlayerUpgradeLevel === 1) {
frameElement = 3;
} else if(shootDelayUpgrade.currentPlayerUpgradeLevel === 1) {
frameElement = 2;
} else {
frameElement = 1;