Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Box2D Examples

 import QtQuick 2.0
 import Felgo 4.0

 EntityBase {

   x: index * 150 + 10
   y: Math.random() * (screen.height / 3)
   rotation: Math.random() * 90

   width: 50
   height: 50

   // the 0/0 of the entity should be the center of the collider and image
   // this is required when a width & height are set to the entity! in that case, the rotation should be applied around the center (which is top-left, not the width/2,height/2 Item.Center which is the default value)
   transformOrigin: Item.TopLeft

   // for distinguishing the box color
   property alias color: rectangle.color

   property alias categories: collider.categories
   property alias collidesWith: collider.collidesWith

   BoxCollider {
     id: collider
     sleepingAllowed: false
     density: 0.001
     friction: 0.3
     restitution: 0.5
     // this gets set by the outside!
     //categories: Box.Category2
     //collidesWith: Box.Category1 | Box.Category3 | Box.Category4

   }
   Rectangle {
     id: rectangle
     anchors.fill: parent
     opacity: 0.5
     // this gets set by the outside!
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded