Wall.qml Example File

demos/StackTheBoxWithEditor/qml/entities/Wall.qml
 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()
     }
   }
 }

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