Forums

OverviewV-Play 1 Support › BuildEntityButton – set properties for the entities that should be created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #5194

    Saims

    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?

    #5195

    Alex
    V-Play Team

    Hi,

    unfortunately there is a mistake in our docu with the creationProperties.

    It should be

    creationProperties: { "isBowlingBird" : true }

    instead of

    creationProperties: { isBowlingBird : true }

     

    Did this solve your problem?

    Best Regards,

    Alexander

    #5196

    Saims

    Nice!!!

    Thank you very much, it solved my problem. :-)

    #5201

    Saims

    Hi,

    I got one more question concerning the BuildEntityButton and the properties and I didn’t want to create a new thread.

    So setting properties like a rotation works fine when dragging an entity into the game. But when I now have e.g. my wall with a rotation of 45, that I already dragged into the game, and I want to change it’s position by picking it up again, and moving it around, it loses it’s set property. Meaning in my case I dragged a wall with rotation 45 into the game, and after picking it up again, the rotation got reset to 0.

    Is this a known bug, or can I do anything against it?

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support