Forums

OverviewV-Play 1 Supportfixture.onContactEnd is called while object collides with other shape › Reply To: fixture.onContactEnd is called while object collides with other shape

OverviewV-Play 1 Supportfixture.onContactEnd is called while object collides with other shape › Reply To: fixture.onContactEnd is called while object collides with other shape
#4457

GP

Now here is a little demo project with the same issue:

Box.qml

EntityBaseDraggable {
    id: box
    entityType: "rectangle"
    entityId: "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


    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}

    }
}

 

BoxPreview.qml

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;

     }

    Rectangle {
        height: 20
        width: 20
        color: "yellow"
        anchors.fill: parent
    }

}

 

main.qml

import VPlay 1.0
import Box2D 1.0
import QtQuick 1.1

GameWindow {
    activeScene: scene
    // 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
    }
    
    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}
        }

        Rectangle {
            width: 150
            height: 20
            color: "grey"

            x:50
            y:200

            BoxCollider {
                anchors.fill: parent
                bodyType: Body.Static
            }
        }

        PhysicsWorld {
            id: physicsWorld
            gravity.y: -9.81
            z: 10


            updatesPerSecondForPhysics: 60
            velocityIterations: 5
            positionIterations: 5
        }


    }
}

 

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