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.

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