LoadingScene.qml Example File

demos/Squaby/qml/otherScenes/LoadingScene.qml
 import QtQuick 2.0
 import VPlay 2.0

 // is shown at game start and shows the maximum highscore and a button for starting the game
 SquabySceneBase {
   id: loadingScene

   state: "exited"

   signal finishedLoadingAnimation

   MultiResolutionImage {
     source: "../../assets/img/bgSubmenu.png"
     anchors.centerIn: parent
     property int pixelFormat: 3
   }

   MultiResolutionImage {
     id: squabyBg
     source: "../../assets/img/bgMainmenu.png"
     anchors.centerIn: parent
   }

   Text {
     text: "Loading..."
     color: "white"
     font.family: jellyFont.name
     font.pixelSize: 42

     x: 75
     y: 50

   }

   // Called when scene is displayed
   function enterScene() {
     state = "entered"
   }

   onStateChanged: console.debug("LoadingScene.state changed to", state)

   /*onOpacityChanged: {
     console.debug("LoadingScene opacity:", opacity)
     // this would be too early! the cocos opacity would not be affected here
 //    if(opacity >= 1)
 //      finishedLoadingAnimation()
   }*/

   Timer {
     id: opacityAnimationFinishedTimer
     interval: 4*opacityAnimation.duration

     onTriggered: {
       console.debug("finished opacity animation!?")
       finishedLoadingAnimation()

       // switch back to state exited, so the timer can be started again next time the loading scene is entered
       // do NOT change to exited state here, but just when the state is changed
       //loadingScene.state = "exited"
     }

   }

   states: [
     State {
       name: "entered"
       PropertyChanges { target: squabyBg; opacity: 1 }
       StateChangeScript {
         script: {
           opacityAnimationFinishedTimer.start()
         }
       }
     },
     State {
       name: "exited"
       PropertyChanges { target: squabyBg; opacity: 0 }
     }
   ]

   transitions: Transition {
     NumberAnimation {
       id: opacityAnimation
       target: squabyBg
       duration: 900
       property: "opacity"
       easing.type: Easing.InOutQuad
     }
   }
 }

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