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

StackTheBoxWithEditor Demo

 import QtQuick 2.0
 import Felgo 3.0
  // for accessing the Body.Static type

 EntityBase {
   entityType: "wall"

   // this gets used by the top wall to detect when the game is over
   signal collidedWithBox

   // this allows setting the color property or the Rectangle from outside, to use another color for the top wall
   property alias color: rectangle.color

   Rectangle {
     id: rectangle
     color: "blue"
     anchors.fill: parent
   }
   BoxCollider {
     anchors.fill: parent
     // use "" to access the Body.Static type
     bodyType: Body.Static // the body shouldnt move

     fixture.onBeginContact: {
       // for access of the collided entity and the entityType and entityId:
       var collidedEntity = other.getBody().target;
       var collidedEntityType = collidedEntity.entityType;
       // avoid emitting the signal at collision with obstacle while in levelEditing mode
       // otherwise the game would be reset if an obstacle would collide with the top wall
       if(collidedEntityType === "box")
         collidedWithBox()
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded