Obstacle.qml Example File

demos/StackTheBoxWithEditor/qml/entities/Obstacle.qml
 import QtQuick 2.0
 import Felgo 3.0
  // for accessing the Body.Static type

 EntityBaseDraggable {
   id: obstacle
   entityType: "obstacle"

   width: 32
   height: 32

   colliderComponent: collider

   selectionMouseArea.anchors.fill: rectangle

   // the gridSize can also be smaller than the width, then the levels do not look as blocky and it is not a real grid
   gridSize: 16
   colliderSize: width

   // this item will blink when the entity is selected
   opacityChangeItemWhileSelected: rectangle

   onEntityClicked: scene.entitySelected(obstacle)

   // if the obstacle was pressed and held, remove it
   onEntityPressAndHold: removeEntity()

   Rectangle {
     id: rectangle
     color: "grey"
     x: -width/2
     y: -height/2
     width: parent.width
     height: parent.height
   }
   BoxCollider {
     id: collider
     x: -width/2
     y: -height/2
     // this is set automatically from BoxCollider
 //    width: parent.width
 //    height: parent.height

     // use "" to access the Body.Static type
     bodyType: Body.Static // the body shouldnt move

   }
 }

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