Forums

OverviewV-Play 1 Support › BuildEntityButton – create entity

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #4890

    phil.jahoda

    Hello.

    We are currently working on a level – editor and trying to use the BuildEntityButton to create our own entities when clicking it.

    Unfortunately, when we click our BuildEntityButton and start dragging, we get an error message as follows:

     

    BuildEntityButton: button MouseArea pressed, start dragging entity
    file::/qml/VPlay/level/BuildEntityButton.qml:292:3: QML MouseArea: mapToItem() given argument "undefined" which is neither null nor an Item
    file::/qml/VPlay/level/BuildEntityButton.qml:307: TypeError: Result of expression 'createdEntity' [undefined] is not an object.

    This is the entity that we want to create:

    import QtQuick 1.1
    import VPlay 1.0
    
    EntityBaseDraggable {
    
        entityType: "block"
        z: 1
    
        selectionMouseArea.anchors.fill: rectangle
        colliderComponent: collider
    
        gridSize: 32
        // the collider's size is exactly 1x1 grid
        colliderSize: 32
    
        Rectangle {
            id: rectangle
            width: 32
            height: 32
            color: "brown"
        }
    
        BoxCollider {
            id: collider
            anchors.fill: rectangle
        }
    }

    And here is the Scene that uses the BuildEntityButton:

    import QtQuick 1.1
    import VPlay 1.0
    
    CrazyElephantSceneBase {
    
        BuildEntityButton {
    
            id: entitybutton
            x: 50
            y: 50
            width: 50
            height: 50
            toCreateEntityType: "entities/DraggableEntity.qml"
    
            Image {
    
              // make it the size of the parent
              anchors.fill: parent
              source: "img/block.png"
            }
    
        }
    }

     

    What are we doing wrong?

    #4891

    Christian
    V-Play Team

    Hi Phil,

    are you using the latest daily build 1.3.4, as there were some bug fixes regarding BuildEntityButton and EntityBaseDraggable added in this version? Did you also use the CONFIG += v-play_daily flag in your pro file (and make sure to run qmake and clean the project before, as another static library, the daily build one, is used)?

    If these preconditions are met, could you please check if there are any errors or warnings in the log output?

    One hint regarding your code:please do not use an anchors.fill for the colliderComponent you use for EntitBaseDraggable, as the collider size gets changed internally while the entity is dragged. We will fix this issue with the next daily build, but until then just set the width to your desired image size and use the anchor on the image not the collider, as we have done it in the StackTheBoxWithEditor demo for Obstacle: http://v-play.net/doc/daily/demos-stacktheboxwitheditor-qml-entities-obstacle-qml.html

    Cheers, Chris

    #4892

    Saims

    Hi,

    yes, we are using the latest daily build, but we forgot the CONFIG += v-play_daily flag. After setting it, i cleaned the project, used qmake and rebuilt the project, but the build failed with the following errors:

     

    :-1: Fehler:14 duplicate symbols for architecture x86_64
    :-1: Fehler:collect2: ld returned 1 exit status

     

    #4893

    Christian
    V-Play Team

    Could you try to first run qmake and then clean again? Could you also try if the empty V-Play Project template works for your a new project with the daily build config enabled in the pro file?

    #4940

    phil.jahoda

    After running qmake, clean and remake all we are still getting the same error when we click the BuildEntityButton in our Scene and drag (for every dragged Pixel, a new Log output with that error occurs):

    file::/qml/VPlay/level/BuildEntityButton.qml:328: TypeError: Result of expression 'createdEntity' [undefined] is not an object.

     

    We created a new V-Play project and only copied our QML folder to the new project.

    We also made changes in our .pro file, it now looks as follows:

    # V-Play project
    CONFIG += v-play_daily
    
    # V-Play Demo Game
    customFolder.source = qml
    DEPLOYMENTFOLDERS += customFolder
    
    # Add sources
    SOURCES += main.cpp

     

    These two errors (as described before) are now gone:

    :-1: Fehler:14 duplicate symbols for architecture x86_64
    
    :-1: Fehler:collect2: ld returned 1 exit status

     

     

    #4941

    Christian
    V-Play Team

    Could you extract an example that shows the parts that are not working and past it here please?

    Furthermore, please look for the debug output that starts with “BuildEntityButton: created entity:” and paste it here. Do you have any other errors in the log except the one you posted above, when starting your game?

    Cheers, Chris

    #4942

    phil.jahoda

    A simple example:

    We have a Scene looking like this:

    It contains a BuildEntityButton displaying the Image of a Box. The displaying of the scene and button works fine. When I click the button and drag it, I want to create a new Block from it and be able to place it somewhere on the screen.

    import QtQuick 1.1
    import VPlay 1.0
    
    Scene {
    
        BuildEntityButton {
    
            id: entitybutton
            x: 50
            y: 50
            width: 50
            height: 50
            toCreateEntityType: "entities/DraggableEntity.qml"
    
            Image {
    
              // make it the size of the parent
              anchors.fill: parent
              source: "img/block.png"
            }
    
        }
    }
    

     

    My “Block” Item is represented by the class DraggableEntity.qml looking like this: (Its not more than a brown Rectangle)

    This should be the entity that is created when I click the BuildEntityButton in the scene.

    import QtQuick 1.1
    import VPlay 1.0
    
    EntityBaseDraggable {
    
        entityType: "block"
        z: 1
    
        selectionMouseArea.anchors.fill: rectangle
        colliderComponent: collider
    
        gridSize: 32
        // the collider's size is exactly 1x1 grid
        colliderSize: 32
    
        Rectangle {
            id: rectangle
            width: 32
            height: 32
            color: "brown"
        }
    
        BoxCollider {
            id: collider
            anchors.fill: rectangle
        }
    }
    

     

    But when I click our button, this error occurs and repeats itself when dragging:

    BuildEntityButton: button MouseArea pressed, start dragging entity
    file::/qml/VPlay/level/BuildEntityButton.qml:292:3: QML MouseArea: mapToItem() given argument "undefined" which is neither null nor an Item
    file::/qml/VPlay/level/BuildEntityButton.qml:307: TypeError: Result of expression 'createdEntity' [undefined] is not an object.
    file::/qml/VPlay/level/BuildEntityButton.qml:326: TypeError: Result of expression 'createdEntity' [undefined] is not an object.
    file::/qml/VPlay/level/BuildEntityButton.qml:327: TypeError: Result of expression 'createdEntity' [undefined] is not an object. .........

     

    #4943

    Alex
    V-Play Team

    Hi,

     

    we were able to replicate your error and found the solution.

     

    At the moment there are dependencies to the id of the Scene. Please add “id: scene” to the Scene Component. We will fix this issue in the next daily build, to allow custom scene ids.

     

    Also make sure that you have used the PhysicsWorld component if you are using any Colliders.

     

    Let me know if this fixed your problems.

     

    Best Regards,
    Alexander

    #4947

    phil.jahoda

    Thank you very much, changing our scene’s id to “scene” really eliminated the previously described error.

    Unfortunately, a new error new occurs when dragging and releasing: 😀

    BuildEntityButton: button MouseArea pressed, start dragging entity
    EntityBaseDraggable: storing property active with value false
    EntityBaseDraggable: storing property state with value 
    EntityBaseDraggable: storing property bodyType with value 2
    EntityBaseDraggable: storing property implicitHeight with value 0
    EntityBaseDraggable: storing property smooth with value false
    EntityBaseDraggable: storing property width with value 32
    EntityBaseDraggable: storing property visible with value false
    EntityBaseDraggable: storing property clip with value false
    EntityBaseDraggable: storing property bullet with value false
    EntityBaseDraggable: storing property density with value 0
    EntityBaseDraggable: storing property collidesWith with value 65535
    EntityBaseDraggable: storing property groupIndex with value 0
    EntityBaseDraggable: storing property focus with value false
    EntityBaseDraggable: storing property baselineOffset with value 0
    EntityBaseDraggable: storing property angularVelocity with value 0
    EntityBaseDraggable: storing property collisionTestingOnlyMode with value false
    EntityBaseDraggable: storing property fixedRotation with value false
    EntityBaseDraggable: storing property scale with value 1
    EntityBaseDraggable: storing property activeFocus with value false
    EntityBaseDraggable: storing property categories with value 1
    EntityBaseDraggable: storing property opacity with value 1
    EntityBaseDraggable: storing property rotation with value 0
    EntityBaseDraggable: storing property angularDamping with value 0
    EntityBaseDraggable: storing property restitution with value 0
    EntityBaseDraggable: storing property transformOrigin with value 4
    EntityBaseDraggable: storing property sleepingAllowed with value true
    EntityBaseDraggable: storing property objectName with value boxCollider
    EntityBaseDraggable: storing property torque with value 0
    EntityBaseDraggable: storing property friction with value 0.20000000298023224
    EntityBaseDraggable: storing property x with value 0
    EntityBaseDraggable: storing property enabled with value true
    EntityBaseDraggable: storing property y with value 0
    EntityBaseDraggable: storing property z with value 0
    EntityBaseDraggable: storing property sensor with value false
    EntityBaseDraggable: storing property height with value 32
    EntityBaseDraggable: storing property implicitWidth with value 0
    EntityBaseDraggable: storing property linearDamping with value 0
    Box2DBody: calling sychronize after active got set to true 
    BuildEntityButton: entity got pressed: EntityBaseDraggable_QMLTYPE_76(0x114c8c730, "file:///Users/philipp/CrazyElephant-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/CrazyElephant.app/Contents/Resources/qml/entities/DraggableEntity.qml_96") , for creationType: file:///Users/philipp/CrazyElephant-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/CrazyElephant.app/Contents/Resources/qml/entities/DraggableEntity.qml
    pos of createdEntity: 73 8
    Cocos2DWrapper: updateItemPositionAndRotationImmediately: parentPosOfTopLeft: QPointF(73, 8) EntityBaseDraggable_QMLTYPE_76 (this = 0x114c8c730 , parent = 0x10fde6d50 , geometry = QRectF(73,8 0x0) , z = 1 ) 
    the position really changed, so call all children recursively 
    Cocos2DWrapper: callTransformForAllChildrenRecursively() for node 0x103bdea20 
    Cocos2DWrapper: callTransformForAllChildrenRecursively() for node 0x103bdd370 
    Cocos2DWrapper: callTransformForAllChildrenRecursively() for node 0x103bdd4c0 
    Cocos2DWrapper: callTransformForAllChildrenRecursively() for node 0x103be3200 
    Cocos2DWrapper: callTransformForAllChildrenRecursively() for node 0x103be3350 
    entityReleased position: 238.5 72 snapped position: 224 64
    EntityBaseDraggable: restoring property active to initial value false , current value: true of colliderComponent BoxCollider_QMLTYPE_27(0x114c9c9b0, "boxCollider")
    EntityBaseDraggable: restoring property categories to initial value 1 , current value: 65535 of colliderComponent BoxCollider_QMLTYPE_27(0x114c9c9b0, "boxCollider")
    EntityBaseDraggable: restoring property collisionTestingOnlyMode to initial value false , current value: true of colliderComponent BoxCollider_QMLTYPE_27(0x114c9c9b0, "boxCollider")
    entity got released, create it at the position if allowed to build
    DragEntity: no creationProperties were defined
    EntityManager: createEntityFromUrl: file:///Users/philipp/CrazyElephant-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/CrazyElephant.app/Contents/Resources/qml/entities/DraggableEntity.qml
    VisualItemPropertyObserver componentComplete for item EntityBaseDraggable_QMLTYPE_76 (this = 0x110f3adb0 , parent = 0x10fde6d50 , geometry = QRectF(224,64 0x0) , z = 1 ) 
    file::/qml/VPlay/core/EntitySelection.qml:15: Unable to assign [undefined] to QObject* target
    file::/qml/VPlay/core/EntitySelection.qml:9: ReferenceError: Can't find variable: sprite
    EntityManager: entity created with id file:///Users/philipp/CrazyElephant-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/CrazyElephant.app/Contents/Resources/qml/entities/DraggableEntity.qml_99
    GameWindow: creating cocos item in cocosWrapper triggered by JavaScript code explicitly: EntityBaseDraggable_QMLTYPE_76(0x110f3adb0, "file:///Users/philipp/CrazyElephant-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/CrazyElephant.app/Contents/Resources/qml/entities/DraggableEntity.qml_99")

     

    PS: I added a physics world to our Scene and set the EntityBaseDraggable properties “allowedToBuild” and “clickingAllowed” to true.

    #4986

    Alex
    V-Play Team

    We released a new daily build yesterday. Please check if the issue still occurs with the new version.

     

    Best Regards,

    Alexander

    #5011

    phil.jahoda

    I just made the update but the error still occurs. It seems as if something in the class “EntitySelection” is not working properly as you can see in the last lines of the error message.

    Furthermore, could our error have something to do with the “storing property…” of the EntityBaseDraggable as you can see it in the Log output?

    Do you see any errors or missing/wrong properties in the code of our EntityBaseDraggable that is shown above?

    Here again the error message:

    BuildEntityButton: button MouseArea pressed, start dragging entity
    EntityBaseDraggable: storing property active with value false
    EntityBaseDraggable: storing property state with value 
    EntityBaseDraggable: storing property bodyType with value 2
    EntityBaseDraggable: storing property implicitHeight with value 0
    EntityBaseDraggable: storing property smooth with value false
    EntityBaseDraggable: storing property width with value 32
    EntityBaseDraggable: storing property visible with value false
    EntityBaseDraggable: storing property clip with value false
    EntityBaseDraggable: storing property bullet with value false
    EntityBaseDraggable: storing property density with value 0
    EntityBaseDraggable: storing property collidesWith with value 65535
    EntityBaseDraggable: storing property groupIndex with value 0
    EntityBaseDraggable: storing property focus with value false
    EntityBaseDraggable: storing property baselineOffset with value 0
    EntityBaseDraggable: storing property angularVelocity with value 0
    EntityBaseDraggable: storing property collisionTestingOnlyMode with value false
    EntityBaseDraggable: storing property fixedRotation with value false
    EntityBaseDraggable: storing property scale with value 1
    EntityBaseDraggable: storing property activeFocus with value false
    EntityBaseDraggable: storing property categories with value 1
    EntityBaseDraggable: storing property opacity with value 1
    EntityBaseDraggable: storing property rotation with value 0
    EntityBaseDraggable: storing property angularDamping with value 0
    EntityBaseDraggable: storing property restitution with value 0
    EntityBaseDraggable: storing property transformOrigin with value 4
    EntityBaseDraggable: storing property sleepingAllowed with value true
    EntityBaseDraggable: storing property objectName with value boxCollider
    EntityBaseDraggable: storing property torque with value 0
    EntityBaseDraggable: storing property friction with value 0.20000000298023224
    EntityBaseDraggable: storing property x with value 0
    EntityBaseDraggable: storing property enabled with value true
    EntityBaseDraggable: storing property y with value 0
    EntityBaseDraggable: storing property z with value 0
    EntityBaseDraggable: storing property sensor with value false
    EntityBaseDraggable: storing property height with value 32
    EntityBaseDraggable: storing property implicitWidth with value 0
    EntityBaseDraggable: storing property linearDamping with value 0
    Box2DBody: calling sychronize after active got set to true 
    BuildEntityButton: entity got pressed: EntityBaseDraggable_QMLTYPE_76(0x111181c60, "file:///Users/philipp/CrazyElephant-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/CrazyElephant.app/Contents/Resources/qml/entities/DraggableEntity.qml_96") , for creationType: file:///Users/philipp/CrazyElephant-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/CrazyElephant.app/Contents/Resources/qml/entities/DraggableEntity.qml
    pos of createdEntity: 79 6.5
    Cocos2DWrapper: updateItemPositionAndRotationImmediately: parentPosOfTopLeft: QPointF(79, 6.5) EntityBaseDraggable_QMLTYPE_76 (this = 0x111181c60 , parent = 0x1042e1920 , geometry = QRectF(79,6.5 0x0) , z = 1 ) 
    the position really changed, so call all children recursively 
    Cocos2DWrapper: callTransformForAllChildrenRecursively() for node 0x114eef8f0 
    Cocos2DWrapper: callTransformForAllChildrenRecursively() for node 0x114ef0480 
    Cocos2DWrapper: callTransformForAllChildrenRecursively() for node 0x114ef05d0 
    Cocos2DWrapper: callTransformForAllChildrenRecursively() for node 0x114eefb70 
    Cocos2DWrapper: callTransformForAllChildrenRecursively() for node 0x114eefcc0 
    entityReleased position: 387 155.5 snapped position: 384 160
    EntityBaseDraggable: restoring property active to initial value false , current value: true of colliderComponent BoxCollider_QMLTYPE_27(0x111192650, "boxCollider")
    EntityBaseDraggable: restoring property categories to initial value 1 , current value: 65535 of colliderComponent BoxCollider_QMLTYPE_27(0x111192650, "boxCollider")
    EntityBaseDraggable: restoring property collisionTestingOnlyMode to initial value false , current value: true of colliderComponent BoxCollider_QMLTYPE_27(0x111192650, "boxCollider")
    entity got released, create it at the position if allowed to build
    DragEntity: no creationProperties were defined
    EntityManager: createEntityFromUrl: file:///Users/philipp/CrazyElephant-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/CrazyElephant.app/Contents/Resources/qml/entities/DraggableEntity.qml
    VisualItemPropertyObserver componentComplete for item EntityBaseDraggable_QMLTYPE_76 (this = 0x1042d3720 , parent = 0x1042e1920 , geometry = QRectF(384,160 0x0) , z = 1 ) 
    file::/qml/VPlay/core/EntitySelection.qml:15: Unable to assign [undefined] to QObject* target
    file::/qml/VPlay/core/EntitySelection.qml:9: ReferenceError: Can't find variable: sprite
    EntityManager: entity created with id file:///Users/philipp/CrazyElephant-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/CrazyElephant.app/Contents/Resources/qml/entities/DraggableEntity.qml_99
    GameWindow: creating cocos item in cocosWrapper triggered by JavaScript code explicitly: EntityBaseDraggable_QMLTYPE_76(0x1042d3720, "file:///Users/philipp/CrazyElephant-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Debug/CrazyElephant.app/Contents/Resources/qml/entities/DraggableEntity.qml_99")

     

     

    #5032

    Alex
    V-Play Team

    Did you clean your project before building it after the update? You recieve an output that was changed in the latest version.

     

    “EntityManager: entity created with id …” should now be “EntityManager: entity created with entityId: …”

    #5037

    phil.jahoda

    I updated to the latest V-Play SDK Version using the V-Play MaintenanceTool.

    After that I used qmake, clean and rebuilt the whole project. Still the log output says “EntityManager: entity created with id …”

     

    Our .pro file currently looks like this:

    
    # V-Play Empty Project
    customFolder.source = qml
    DEPLOYMENTFOLDERS += customFolder
    
    # if Symbian or Meego want to be addressed, have a look at the demo games how to set up the capabilities for Symbian and the desktop icon for Meego
    
    # Add sources
    SOURCES += main.cpp
    
    # this must be written AFTER deploymentfolders was defined!
    include($$PWD/projectinclude.pri)
    
    OTHER_FILES +=
    

     

    Unfortunately, the “CONFIG += v-play_daily” still causes the following error (when building) when we use it in our .pro file:

    :-1: Fehler:14 duplicate symbols for architecture x86_64
    :-1: Fehler:collect2: ld returned 1 exit status

     

    #5038

    Alex
    V-Play Team

    phil.jahoda said:

    Unfortunately, the “CONFIG += v-play_daily” still causes the following error (when building) when we use it in our .pro file:

    :-1: Fehler:14 duplicate symbols for architecture x86_64
    :-1: Fehler:collect2: ld returned 1 exit status

     

    Hi,

    the error occurs because you’re targeting both, V-Play daily and V-Play stable release libraries. Please update your pro file like described here for projects targeting V-Play 1.3.x and above (tldr: Remove the include($$PWD/projectinclude.pri) line and add a CONFIG += v-play or CONFIG += v-play_daily depending on your preferred libraries).

    Cheers,

    Alex

    #5054

    phil.jahoda

    Thank you for your response, the error in the .pro file is now gone.

    Furthermore, I was able to figure out why our BuildEntityButton did not work. It turned out that I was using the wrong id in the EntityManager. After changing that I can now finally create entities.

     

    I am currently reading this tutorial about saving Levels with the LevelEditor, as we want to save our levels this way. Unfortunately I cannot use the “LevelEditor” type in my .qml file and it is underlined with the error message “unknown type”.

     

    I made all V-Play SDK updates and even checked my V-Play SDK folder if the required .qml files are present (and they are there).

    It seems to me as if something is not “imported” correctly. What else do I have to do to use the LevelEditor?

     

    Using the LevelEditor like this will cause “LevelEditor” to be underlinded red with the error message “unknown type”:

    import QtQuick 1.1
    import VPlay 1.0
    import Box2D 1.0
    
    CrazyElephantSceneBase {
    
        id: scene
        
        LevelEditor { // THIS IS UNDERLINED RED
            id: levelEditor
        }
    
        // ...
    }

     

Viewing 15 posts - 1 through 15 (of 17 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