Forums

OverviewV-Play 2 Support (Qt 5)Walls collisions doesnt works › Reply To: Walls collisions doesnt works

OverviewV-Play 2 Support (Qt 5)Walls collisions doesnt works › Reply To: Walls collisions doesnt works
#7516

Vlad

ok, some mystic:

here is level01.qml

import QtQuick 2.0
import "entities"

Item {
    id: _root
    //anchors.fill: parent
    x: 0
    y: 0
    width: parent.width
    height: parent.height
    
    // these entities will be created when the game launches

    Wall {
        height: 1
        width: parent.width
        y: 0
        x: 0
        variationType: "ceil"
    }

    Wall {
        height: 1
        width: parent.width
        y: parent.height
        x: 0
        variationType: "floor"
    }
    
    Wall {
        width: 1
        height: _root.height
        x: 0
        y: 0
        boxColliderX: 1
        variationType: "left"
        onHeightChanged: console.log("level01 wall h:", height)
    }
    
    Wall {
        width: 1
        height: _root.height
        x: parent.width
        y: 0
        variationType: "right"
        boxColliderX: 1
    }

    Component.onCompleted: {
        entityManager.createPooledEntitiesFromUrl(Qt.resolvedUrl("entities/Corn.qml"))
    }
    onWidthChanged: console.log("leel01 w:", width)
    onHeightChanged: console.log("leel01 h:", height)
}

here is Wall.qml

import QtQuick 2.0
import VPlay 2.0
//import Box2D 1.0


EntityBase {
    id: entity
    entityType: "wall"
    collidersActive: true
    preventFromRemovalFromEntityManager: true
    property alias boxColliderX: boxCollider.x
    property alias boxColliderY: boxCollider.y

    BoxCollider {
        id: boxCollider
        categories: Box.Category1
        //collisionTestingOnlyMode: true
        // the wall shouldnt move
        bodyType: Body.Static
        anchors.fill: rect
    }

    
    Rectangle {
        id: rect
        color: "brown"
        anchors.fill: parent
    }
}

 

turning on debug draws in PhysicsWorld I’ve discovered that only one wall (variationType:  “right”) gets correct size of parent.height/width

there rest elements gets something about 32 pixels

If I set numbers explicitly, everything works ok

 

can you explain this?

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