Platformer with Level Editor
import QtQuick 2.0
import Felgo 3.0
BuildEntityButton {
property int buttonSize: 32
property bool isSelected: false
width: buttonSize
height: buttonSize
anchors.horizontalCenter: parent.horizontalCenter
initialEntityPosition: Qt.point(-100, 0)
variationType: createdEntity ? createdEntity.variationType : ""
signal selected
signal unselected
Rectangle {
id: selectedRectangle
visible: isSelected
width: parent.width + 8
height: parent.height + 8
anchors.centerIn: parent
radius: 3
color: "white"
}
Rectangle {
id: background
anchors.fill: buttonImage
radius: 3
color: "#a0b0b0b0"
}
MultiResolutionImage {
id: buttonImage
source: createdEntity ? createdEntity.image.source : ""
width: isSelected ? 36 : 32
height: isSelected ? 36 : 32
anchors.centerIn: parent
}
onClicked: {
isSelected = !isSelected
if(isSelected)
selected()
else
unselected()
}
onEntityWasBuilt: {
var builtEntity = entityManager.getEntityById(builtEntityId)
if(builtEntity) {
var undoObjectProperties = {"target": builtEntity, "action": "create",
"currentPosition": Qt.point(builtEntity.x, builtEntity.y)}
var undoObject = editorOverlay.undoHandler.createUndoObject(undoObjectProperties)
editorOverlay.undoHandler.push([undoObject])