Squaby Demo
import QtQuick 2.0
import Felgo 4.0
import "../gameScene/hud"
EntityBase {
id: pathSection
entityType: "pathSection"
property variant first
property variant second
property real gridSize: scene.gridSize
transformOrigin: Item.TopLeft
BoxCollider {
collisionTestingOnlyMode: true
x: -width/2
y: -height/2
categories: Box.Category3
collidesWith: Box.Category4
}
Repeater {
id: repeater
SingleSquabySprite {
x: -pathSection.width/2 + width*(index+1)
y: -height/2
source: Qt.resolvedUrl("../../assets/img/steps/steps-6-straight.png")
}
}
Component.onCompleted: {
var rot = calculateRotation();
pathSection.rotation = rot
var numberSteps = (width-4*gridSize) / (2*gridSize)
repeater.model = numberSteps
}
function calculateRotation () {
if(second.x>first.x) {
return 0;
} else if(second.x < first.x) {
return 180;
} else if(second.y > first .y) {
return 90;
} else
return 270;