Forums

OverviewV-Play 1 Support › Bugs after update to version 1.4

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #5607

    GP

    Hi guys,

    we updated v-play a few days ago and we noticed some bugs they were not there before the update.

    – text is cutted (and also a linebreak is now in the text, see screenshot: http://imgur.com/KjK39My)

    – if we create an entity by using BuildEntityButton and EntityBaseDraggable the entity will be created twice (instead of once)

    – some buttons are not clickable anymore

    – fixture.onBeginContact does not get called like before (only if the EntityBaseDragabble is not in dragged mode so it just gets called when it’s released)

     

    Did we miss anything after the update (with v-play maintenance tool) or do we have to set some new/changed properties?

     

    Cheers!

    #5608

    Christian
    V-Play Team

    Hi,

    which version did you use before, and do all the issues you mentioned work with your previous version?

    Could you also provide more details for the issue “Some buttons are not clickable anymore”?

    Cheers, Chris

    #5609

    GP

    Hi Chris,

    thanks for your quick response!

    We used version 1.3.0 before and we had none of the issues mentioned above.

     

    I think the issue with the button is not the button itself it is more an issue with the loading of a new scene. We change the state of the window where the activeScene is getting set.

     MenuButton {
         text: "Main Menu"
    
         onClicked: {
            window.state = "main"
            // reset level
            scene.currentLevel.resetLevels();
         }
    }

     

    Here we change the scene:

    onStateChanged: {
            if (state === "main") // Menu
            {
                activeScene = startMenu
                startMenu.enterScene();
            }
    }

     

    Cheers,

    Gregor

    #5740

    GP

    Hi,

    we’ve created an demo example which shows our problem with EntityBaseDraggable. Here’s the code:

    BoxPreview.qml

    import QtQuick 1.1
    import VPlay 1.0
    import Box2D 1.0
    
    BuildEntityButton {
        id: ballPreview
        toCreateEntityType: "Box.qml"
        width: 20
        height: 20
    
        property int shapeWidth: 20
        property int shapeHeight: 20
    
        creationProperties: {
            "sWidth": shapeWidth,
            "sHeight": shapeHeight,
            "isPlaced": true
        }
    
        onEntityPressed: {
            createdEntity.isPlaced = false;
        }
    
        onVisibleChanged: {
          if(!visible) {
            createdEntity.visible = false;
            createdEntity.preventFromRemovalFromEntityManager = false;
          }
        }
    
        Rectangle {
            height: 20
            width: 20
            color: "yellow"
            anchors.fill: parent
        }
    }
    

    Box.qml

    // import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
    import QtQuick 1.1
    import VPlay 1.0
    import Box2D 1.0
    
    EntityBaseDraggable {
        id: box
        entityType: "box"
    
        colliderComponent: boxCollider
        selectionMouseArea.anchors.fill: rect
        gridSize: 1
        height: 20
        width: 20
        dragOffset: Qt.point(0,0)
        allowedToBuild: true
    
        property alias sWidth: rect.width
        property alias sHeight: rect.height
        property bool isPlaced: false
    
        showRectangleWhenBuildingNotAllowed: false
        preventFromRemovalFromEntityManager: false
    
        Rectangle {
            id: rect
            width: 30
            height: 30
            color: "yellow"
        }
    
        BoxCollider {
            id: boxCollider
            anchors.fill:rect
            density:100
    
            friction: 1.6
            restitution: 0
    
            fixture.onBeginContact: {
                if(!isPlaced) {
                    rect.color = "red";
                    allowedToBuild = false;
                }
            }
    
            fixture.onEndContact:  {
                rect.color = "yellow"
                allowedToBuild = true
            }
        }
    }
    

    main.qml

    import VPlay 1.0
    import Box2D 1.0
    import QtQuick 1.1
    
    GameWindow {
        id: window
        // the size of the Window can be changed at runtime by pressing the number keys 1-6 with QML window active
        // the content of the logical scene size (480x320) gets scaled to the window size based on the scaleMode
        width: 960
        height: 640
    
        EntityManager {
            id: entityManager
            entityContainer: scene
        }
    
        Button {
            id: restartButton
            text: "Restart"
            width: 200
            height: 80
            anchors.centerIn: parent
            visible: false
            z:1
    
            onClicked: {
                entityManager.removeAllEntities();
                visible = false
            }
        }
    
        Scene {
            id: scene
    
            Row {
                spacing: 5
                anchors {
                    top: parent.top
                    horizontalCenter: parent.horizontalCenter
                }
    
                BoxPreview{shapeHeight: 50; shapeWidth: 50}
                BoxPreview{shapeHeight: 50; shapeWidth: 50}
                BoxPreview{shapeHeight: 50; shapeWidth: 50}
            }
    
            // platform (here you can place shapes)
            Rectangle {
                width: 300
                height: 30
    
                anchors.centerIn: parent
    
                color: "blue"
    
                BoxCollider {
                    anchors.fill: parent
                    bodyType: Body.Static
                }
            }
    
            // ground (if shape falls on ground, game is over)
            Rectangle {
                width: parent.width
                height: 5
                color: "grey"
                anchors.bottom: parent.bottom
    
                BoxCollider {
                    anchors.fill: parent
                    bodyType: Body.Static
    
                    fixture.onBeginContact: {
                        restartButton.visible = true;
                    }
                }
            }
    
    
            PhysicsWorld {
                id: physicsWorld
                gravity.y: -9.81
                z: 10
    
                updatesPerSecondForPhysics: 60
                velocityIterations: 5
                positionIterations: 5
            }
        }
    }
    

     

    The problem are the two methods “fixture.onBeginContact” and “fixture.onEndContact”. The entities are always allowed to build and the color does not change if it collides with an other entity. As I remember this worked fine with version 1.3.0, were there any API changes we’ve missed?

     

    Cheers!

    #5743

    Alex
    V-Play Team

    Hi,

    the problem is the following:

    Our old EntitiyBaseDraggable used the collider of the entity to determine if building was allowed of not. Because of this you could use the “fixture.onBeginContact” and “fixture.onEndContact” signals of the collider. But we were overriding some possible property bindings of the original collider internally, so this was no sufficient solution in some cases.

    The new EntityBaseDraggable copies the collider of the entity internally, modifies it without touching the property bindings of the original collider, and uses the copy for collision detection instead. That’s why you are not recieving the signals.

    I have a different solution for you, let me know if this is sufficient for you:

    import QtQuick 1.1
    import VPlay 1.0
    import Box2D 1.0
    
    EntityBaseDraggable {
      id: box
      entityType: "box"
    
      colliderComponent: boxCollider
      selectionMouseArea.anchors.fill: rect
      gridSize: 1
      height: 20
      width: 20
      dragOffset: Qt.point(0,0)
      //allowedToBuild: true
    
      property alias sWidth: rect.width
      property alias sHeight: rect.height
      //property bool isPlaced: false
    
      //showRectangleWhenBuildingNotAllowed: false
      preventFromRemovalFromEntityManager: false
    
      // you can access the properties of the rectangle that is shown when building is not allowed
      notAllowedRectangle.x: 0
      notAllowedRectangle.y: 0
      notAllowedRectangle.opacity: 1
    
      Rectangle {
        id: rect
        width: 30
        height: 30
        color: "yellow"
      }
    
      BoxCollider {
        id: boxCollider
        anchors.fill:rect
        density:100
    
        friction: 1.6
        restitution: 0
    
    //    fixture.onBeginContact: {
    //      if(!isPlaced) {
    //        rect.color = "red";
    //        allowedToBuild = false;
    //      }
    //    }
    
    //    fixture.onEndContact:  {
    //      rect.color = "yellow"
    //      allowedToBuild = true
    //    }
      }
    }
    

    Cheers,
    Alex

     

    #5753

    Alex
    V-Play Team

    And another solution that just came to my mind is using the onAllowedToBuildChanged signal.

    import QtQuick 1.1
    import VPlay 1.0
    import Box2D 1.0
    
    EntityBaseDraggable {
      id: box
      entityType: "box"
    
      colliderComponent: boxCollider
      selectionMouseArea.anchors.fill: rect
      gridSize: 1
      height: 20
      width: 20
      dragOffset: Qt.point(0,0)
      //allowedToBuild: true
    
      property alias sWidth: rect.width
      property alias sHeight: rect.height
      //property bool isPlaced: false
    
      showRectangleWhenBuildingNotAllowed: false
      preventFromRemovalFromEntityManager: false
    
      Rectangle {
        id: rect
        width: 30
        height: 30
        color: "yellow"
      }
    
      BoxCollider {
        id: boxCollider
        anchors.fill:rect
        density:100
    
        friction: 1.6
        restitution: 0
    
    //    fixture.onBeginContact: {
    //      if(!isPlaced) {
    //        rect.color = "red";
    //        allowedToBuild = false;
    //      }
    //    }
    
    //    fixture.onEndContact:  {
    //      rect.color = "yellow"
    //      allowedToBuild = true
    //    }
      }
    
      onAllowedToBuildChanged: {
        if(allowedToBuild === false) rect.color = "red"
        else rect.color = "yellow"
      }
    }
    

    Cheers,
    Alex

    #5795

    GP

    Hi Alex,

    thank you very much for your hints. This is exactly what we needed. One question came up along with your suggestion, how is it possible to get the type of the collided entity? I want to know with which entity type my EntityBaseDraggable collides.

    Cheers,

    Gregor

     

    #5835

    Alex
    V-Play Team

    Hi Gregor,

    currently you have no access to this information while dragging the entity, since only the internal collider copy is active and its signal are not forwarded straight

    We added 2 new signals to the EntityBaseDraggable for your use case, they will be available with the next daily build.

    You can use them like this:

    EntityBaseDraggable {
      // collider and stuff
    
      // these are the new signals of the EntityBaseDraggable
      // you have access to the colliding fixture via "other"
      onBeginContactWhileDragged: {
        var fixture = other;
        var body = other.parent;
        var component = other.parent.parent;
        var collidedEntity = component.owningEntity;
        var collidedEntityType = collidedEntity.entityType;
        console.log("onBeginContactWhileDragged: collided with entity " + collidedEntity)
      }
    
      onEndContactWhileDragged: {
        var fixture = other;
        var body = other.parent;
        var component = other.parent.parent;
        var collidedEntity = component.owningEntity;
        var collidedEntityType = collidedEntity.entityType;
        console.log("onEndContactWhileDragged: collided with entity " + collidedEntity)
      }
    }
    

    Cheers,
    Alex

     

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