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

Forums

OverviewFelgo 1 Support › Detecting application state

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #4707

    Mathias

    Hi

    I have been looking trough the documentation for a way to detect if the application is active running or if it is in the background. For example I would like to pause the game and stop the music when the player switches to an other application or puts the game in the background. I know that on Meego Harmattan this could be handled using the platformWindow element. Does v-play provide any equivalent? How is it working on Android and iOS?

    Thanx.

    Mathias

    P.S. It would be cool if you could add a search here in the forums to more easily browse trough previous forum topics. 🙂

     

     

    #4720

    Alex
    Felgo Team

    Hi Mathias,

    the application state is handled transparently in Felgo, so if an app on Android or iOS gets into background all sounds, animations, timers and so on (so the entire game loop too) get paused and resumed as soon as the app is active again.

    Is this behavior sufficient for your game or are you looking for additional signals getting emitted when an app changes its state?

    Thanks,

    Alex

     

    ps: Thanks for your forum input, we are working on that! 😉

    #4725

    Martin

    Hey,

    I am also somewhat uncertain about the consistent handling of back/home button presses and application switching (e.g. by incoming calls or otherwise) on the different supported platforms. It would be great if you could provide a little tutorial and preferably (and maybe more importantly) also include this in a qtcreator template. I know that it can probably be figured out from some of the demos but it definitely does make sense to include it in a standard template.

     

    Cheers,

    Martin

    #4727

    Christian
    Felgo Team

    Hi, yes we will add a template that shows this functionality! Thanks a lot for your input!

    Cheers, Chris

    #4729

    Mathias

    Thanx for the reply. For my current project i think it will be enough to stop all animations, sounds, timers etc.

    – Mathias

    #5337

    Nour

    hello

     

    my game rejected because back button doesn’t close the game and sometimes music doesn’t stop when lock the device

    Music scenario

    1. Execute the application
    2. Press HOLD key > Release hold mode > Release lock-screen
    3. Check the Sound

    is there any solution for this?

     

    Thanks

    #5338

    Alex
    Felgo Team
    #5381

    David

    Hi maysalward,

    We already fixed the music problem and it is available on the buildserver! Just rebuild your application and it should work fine!

    Cheers,

    David

    #5746

    magicsquare15

    Hi Mathias,

     

    I would also like to be able to “pause” the game.  Actually, I would also like to be able to slow down or speed up time as well, as done in the Android game Xelorians, if anyone here has played this.  Has anyone figured out a way to change what the world’s update time step is?

     

    Thanks,

    Aaron

    #5752

    Alex
    Felgo Team

    Hi Aaron,

    to pause your game (the physics part) you can simply set the “running” property of your PhysicsWorld to false.

    I will have a look if i find an easy way to slow down time.

    Cheers,
    Alex

    #5754

    Alex
    Felgo Team

    Regarding slowing down time:

    We will add the possibility to change the timeStep property of the PhysicsWorld to achieve the effect of slowing down or even speeding up time, to our next daily build. As soon as it’s available, i will post some demo source code here!

    Cheers,
    Alex

    #5763

    Alex
    Felgo Team

    In our next daily build we will introduce a new property to the PhysicsWorld, called timeScale. This will allow you to slow down and speed up time of the physics world.
    Here is some demo source code, showing how you will be able to use the property. Stay tuned!

    import VPlay 1.0
    import Box2D 1.0
    import QtQuick 1.1
    
    GameWindow {
      id: window
      width: 960
      height: 640
    
      EntityManager {
        id: entityManager
      }
    
      Scene {
        id: scene
        width: 960
        height: 640
        Column {
          SimpleButton {
            text: world.running === true ? "pause" : "resume"
            onClicked: {
              world.running = !world.running
            }
          }
          SimpleButton {
            text: "normal"
            onClicked: {
              world.timeScale = 1
            }
          }
          SimpleButton {
            text: "slower"
            onClicked: {
              world.timeScale = 0.2
            }
          }
          SimpleButton {
            text: "faster"
            onClicked: {
              world.timeScale = 2
            }
          }
        }
    
        PhysicsWorld {
          id: world
          gravity.y: -10
          updatesPerSecondForPhysics: 60
          // you can fade changes of timeScale smoothly to achieve an even nicer effect
          Behavior on timeScale {
            NumberAnimation { duration: 500 }
          }
        }
    
        EntityBase {
          width: parent.width
          height: 20
          anchors.bottom: parent.bottom
          BoxCollider {
            anchors.fill: parent
            bodyType: Body.Static
            categories: Box.Category1
            Rectangle {
              color: "green"
              anchors.fill: parent
            }
          }
        }
    
        Repeater {
          model: 100
          EntityBase {
            id: entity
            x: 40 + Math.random()*800
            y: 200 + Math.random()*150
            width: 20
            height: 20
            BoxCollider {
              anchors.fill: parent
              friction: 0
              restitution: 1
              categories: Box.Category2
              collidesWith: Box.Category1
              Rectangle {
                color: "red"
                anchors.fill: parent
              }
            }
          }
        }
      }
    }

    Cheers,
    Alex

    #5874

    Raimonds

    Alex said:

    Hi Mathias,

    the application state is handled transparently in Felgo, so if an app on Android or iOS gets into background all sounds, animations, timers and so on (so the entire game loop too) get paused and resumed as soon as the app is active again.

    Is this behavior sufficient for your game or are you looking for additional signals getting emitted when an app changes its state?

    Thanks,

    Alex

    Hi Alex!

    I’m searching for application state change event too… if i’m playing game and application goes in background, when someone calls etc.. Everything works fine – sounds and timers are stopped. But when application gets focused again – it automatically starts all events and timers. I wanted to show “Resume” button (show Paused state scene), when app is back on screen…

     

    Best Regards,

    Raimonds

    #5881

    Alex
    Felgo Team

    Hey Raimonds,

    as your already stated Felgo games currently auto-start after the app goes to foreground again. If the described behavior is a requirement for one of your games please add this feature to our roadmap thread so our engineers can prioritize it higher in our next feature discussions.

    Thanks,
    Alex

    #5883

    Christian
    Felgo Team

    Hi Raimonds,

    there are 2 functions that are currently not documented, but which you can use to pause and resume your game manually. You can have a look in the Squaby demo or wizard in the SquabyScene.qml and search for system.resumeGameForObject() and system.pauseGameForObject().

    What these functions do, they pause and resume all Timers and animations for the children objects of the item you provide them as a parameter. You can try to click the menu button in a Squaby game, and you will see the level creation and entity movement is paused. So you could trigger a call of pauseGameForObject() when the onApplicationPaused() signal handler is called in GameWindow, and resumeGameForObject() NOT in resume, but when you press your resume button in the game.

    Cheers, Chris

Viewing 15 posts - 1 through 15 (of 16 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded