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 {
   id: trapezoid

   width: 80
   height: 50

   transformOrigin: Item.TopLeft

   // if width is 100 and this is 80, from each side 10 are removed on the top
   property real upperSideWidth: width - 20

   // this is an internal property and cant be set from outside
   property real __deltaFromEachSide: (width-upperSideWidth)/2

   PolygonCollider {
     sleepingAllowed: false
     density: 0.001
     friction: 0.3
     restitution: 0.5
     vertices: [
       Qt.point(0, 0),
       Qt.point(__deltaFromEachSide, trapezoid.height),
       Qt.point(width-__deltaFromEachSide, trapezoid.height),
       Qt.point(trapezoid.width, 0)
     ]
   }

   // this is the full width & height of the trapezoid, also including the cut part
   Rectangle {
     anchors.fill: parent
     color: "blue"
     opacity: 0.5
   }

   // this is the inner part of the trapezoid - at the moment no triangle can be painted
   Rectangle {
     x: __deltaFromEachSide
     width: upperSideWidth
     height: parent.height
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded