Tour Preview

Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 2 Support (Qt 5) › Add fixtures dynamically

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

    Vadim

    Is it possible?

    I try this: (but it’s not working)

    ColliderBase

        {
            id: collider
            bodyType: Body.Static
    
    
            Component.onCompleted:
            {
                var component = Qt.createComponent("qrc:///qml/entities/MyBox.qml");
                if (component.status === Component.Ready) {
                    var col = component.createObject(collider);
                    col.width = 2000;
                    col.height = 20
                    fixtures.push(col)
                }
            }
            onFixturesChanged: console.log("add fixture")
    }
    
    
    MyBoxCollider is simple Box
    
    
    #17453

    Günther
    Felgo Team

    Hi!

    The fixtures of each entity are set through the colliders and should not be modified manually.

    You can dynamically add colliders to your entity, for example like this:

    EntityBase {
        id: entity
        width: 50
        height: 50
    
        Rectangle {
          anchors.fill: parent
          color: "blue"
        }
    
        Component.onCompleted: {
          boxComp.createObject(entity)
        }
      }
    
      Component {
        id: boxComp
        BoxCollider {
          width: 25
          height: 25
          anchors.centerIn: parent
        }
      }

    Best,
    Günther

     

    #17458

    Vadim

    GT said:

    Hi!

    The fixtures of each entity are set through the colliders and should not be modified manually.

    You can dynamically add colliders to your entity, for example like this:

    EntityBase {
        id: entity
        width: 50
        height: 50
    
        Rectangle {
          anchors.fill: parent
          color: "blue"
        }
    
        Component.onCompleted: {
          boxComp.createObject(entity)
        }
      }
    
      Component {
        id: boxComp
        BoxCollider {
          width: 25
          height: 25
          anchors.centerIn: parent
        }
      }

    Best,
    Günther

     

    But what about this  https://github.com/qml-box2d/qml-box2d/issues/35 ?

     

    I have tried to create dynamically from javascript Fixture with point from json and with addFixture added to Body and it is working and drawing right but i get segfault – in presolve contact have fixture = null. So nothing can be done?

    Ps: sorry for my english and thank you for  reply

     

    #17462

    Günther
    Felgo Team

    Hi Vadim!

    It is required for us to have a closer look and do some testing / fixes to resolve possible issues with dynamically adding fixtures this way. If this feature is important for you, we can prioritize this over other features with the included support hours of Felgo Indie or Enterprise.

    Let me know if this is interesting for you!

    Best,
    Günther

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

RSS feed for this thread

You must be logged in to reply to this topic.