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

Durdles - 2-Player Action Game

 import Felgo 4.0
 import QtQuick 2.0
 import "../common"
 import ".."

 // scene with the level selection
 SceneBase {
   id: selectLevelScene

   // signal indicating that a level has been selected
   signal levelPressed(string selectedLevel)

   // background
   Image {
     z: -2
       id:background
       source: Qt.resolvedUrl("../../assets/img/GameBG.png")

       // use this if the image should be centered, which is the most common case
       // if the image should be aligned at the bottom, probably the whole scene should be aligned at the bottom, and the image should be shifted up by the delta between the imagesSize and the scene.y!
       anchors.centerIn: parent
       scale: 0.5
   }

   // back button to leave scene
   MenuButton {
     label.height: 45
     label.width: 45
     label.source: Qt.resolvedUrl("../../assets/img/Back.png")
     color: "transparent"
     z: 10
     anchors.right: gameWindowAnchorItem.right
     anchors.verticalCenter: gameWindowAnchorItem.verticalCenter
     onClicked: {
       GameInfo.redVictory = 0
       GameInfo.blueVictory = 0
       selectLevelScene.backButtonPressed()
     }
   }

   // header
   Text {
     id: headerText
     text: "Levels"
     color: "black"
     font.family: standardFont.name
     font.pixelSize: 36
     anchors.horizontalCenter: parent.horizontalCenter
     anchors.top: parent.top
     anchors.topMargin: 130
   }

   // tutorial hint
   Text {
     id: tutorial
     text: "Tutorial"
     color: "#54A4BF"
     font.family: standardFont.name
     font.pixelSize: 16
     anchors {
       top: parent.top
       topMargin: 168
       left: parent.left
       leftMargin: 29
     }
   }

   // show selectable levels
   Grid {
     anchors.centerIn: parent
     spacing: 2
     columns: 5

     // repeater adds 10 levels to grid
     Repeater {
       model: 10
       delegate: Rectangle { // delegate describes the structure for each level item
         width: 52
         height: 52
         radius: 12
         color: "white"

         Rectangle {
           width: 44
           height: 44
           anchors.centerIn: parent
           radius: 11
           color: "#54A4BF"

           Rectangle {
             width: 40
             height: 40
             anchors.centerIn: parent
             radius: 10
             color: "white"

             MenuButton {
               property int level: index + 1 // index holds values from 0 to 9 (we set our repeater model to 10)
               text: level
               width: 36
               height: 36
               anchors.centerIn: parent
               buttonText.color: "#54A4BF"
               buttonText.font.family: standardFont.name
               buttonText.font.pixelSize: 24
               onClicked: {
                 var levelFile = "Level_"+level+".qml";
                 if(level < 10)
                   levelFile = "Level_0"+level+".qml";
                 levelPressed(levelFile) // e.g. Level_01.qml, Level_02.qml, ... Level_10.qml
               }
             }
           }
         }
       }
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded