Forums

OverviewV-Play 2 Support (Qt 5) › V-Play 2.6 issues

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

    Phil

    Hi. Since updating to V-Play 2.6, I’m having a couple of problems accessing the properties of some entities and boxColliders. In V-Play 2.5 I can access a property I defined by using: selectedBody.parent.myProperty, but I’m now getting an error. I’ve included some example code below. Thanks, Phil

     

    Common.LevelBase {
        //...
    
        EntityBase {
            //...
            
            MouseArea {
                //...
            
                onPositionChanged: {
                    selectedBody = physicsWorld.bodyAt(Qt.point(mouseX, mouseY))
                    selectedBody.parent.isDead = true    // error in this line
                    var splatid = entityManager.createEntityFromUrlWithProperties(Qt.resolvedUrl("Splat.qml"),{x:selectedBody.getWorldCenter().x, y:selectedBody.getWorldCenter().y})
                    var splat = entityManager.getEntityById(splatid)
                    splat.colorString = selectedBody.parent.colorString    // error in this line
                }
            }
        }
    }

    The qml files for my entities are:

    EntityBase {
        //...
    
        property bool isDead: false
        property string colorString: "green"
        
        BoxCollider {
            //...
        }
    }

    and Splat.qml :

    EntityBase {
        //...
    
        property string colorString: "red"
        
        Image {
            //...
        }
    }

     

    #11005

    Günther
    V-Play Team

    Hi Phil!

    Many things changed with the Box2D update, including how to access the associated entity of a body.
    There is a new property target now, so “selectedBody.target.colorString” should work.
    You can have a look at the Box 2D Upgrade Guide to see what else has changed.

    Best,
    Günther

    #11290

    Phil

    Hi Günther. Thanks for your help. Using the property target solved some of my problems. However, I find that if I define my own property within a boxCollider I cannot access it. Is it no longer possible to do this in the update? If so, I shall avoid this in the future. Thanks, Phil

     

    BoxCollider {
    
        property double myProperty
    
        //...
    }

     

    #11292

    Günther
    V-Play Team

    Hi Phil!

    Currently, it is not possible anymore to directly access the collider object that is linked with the box2d body.
    To get your game to work again, you could introduce a property alias within your entity that allows to access the collider properties.

        EntityBase {
          // ...
    
          property alias collider: collider
    
          BoxCollider {
            id: collider
            property string myProperty: "Hello from Collider!"
            // ...
          }
        }
    
        function myFunction() {
          var body = world.bodyAt(...)
          var entity = body.target
          var collider = entity.collider
          console.log("COLLIDER-PROPERTY: "+collider.myProperty)
        }
    
    

    Of course, you can also move your properties to the entity and keep the collider clean, if you prefer that.

     

    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