Hi,
I’m just trying to give the entity I’m building a specific property. In my case I want to create a Bird. In our Bird.qml there is the property “property bool isBowlingBird: false” and now I want an BuildEntityButton, that sets this value to true when I build the Bird. (Bird gets another appearance and behaves differently when hit)
Another example, where we need to set a property when dragging it into the level would be with our wall, where we want to set a rotation.
I used the code I could find in the BuildEntityButton’s docu, but it doesn’t work. Here my code:
We have a template for all our EntityBaseDraggables (DraggableEntityTemplate):
EntityBaseDraggable {
id:draggableTemplate
// settings for the draggable
clickingAllowed: false
allowedToBuild: true
draggingAllowed: true
gridSize: 20
// the collider's size is exactly 1x1 grid
colliderSize: 20
property bool levelDraggingMode: false
}
The Bird.qml is a DraggableEntityTemplate with the property isBowlingBird.
We also have a BuildEntityButtonTemplate:
BuildEntityButton {
property alias toCreateEntitySource: image.source
width: 50
height: 50
Image {
id: image
// make it the size of the parent
anchors.fill: parent
}
}
And here is the real EntityButton:
BuildEntityButtonTemplate {
toCreateEntityType: "entities/Bird.qml"
toCreateEntitySource: "img/bird_yellow.png"
width: 30
height: 25
creationProperties: { isBowlingBird: true }
}
Well, this looks for me exactly like your code in the docu. But when I try to drag the Bird into the Level I get these errors:
file::/qml/VPlay/level/BuildEntityButton.qml:317: TypeError: Result of expression 'createdEntity' [undefined] is not an object.
file::/qml/VPlay/level/BuildEntityButton.qml:338: TypeError: Result of expression 'createdEntity' [undefined] is not an object.
file::/qml/VPlay/level/BuildEntityButton.qml:338: TypeError: Result of expression 'createdEntity' [undefined] is not an object.
file::/qml/VPlay/level/BuildEntityButton.qml:338: TypeError: Result of expression 'createdEntity' [undefined] is not an object.
.......
Some more infos: I’m using the latest version of v-play, I’m using v-play_daily, don’t know whether this was needed or not, but I also used qmake, clean and rebuild project. Without setting a creationProp everything works fine and I can drag my common birds/walls into the game.
What am I missing?