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

Forums

OverviewFelgo 3 Support (Qt 5) › Multiscene Multilevel resolution problem

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #11321

    Phil

    Hi. I’m trying to incorporate my game into the Multiscene Multilevel demo. When the player selects a level there is a menu scene where the player selects to start the level, view high scores, etc. The content of this scene scales fine (since it is set by the loader). However when the game starts, the level zooms in on higher resolution devices so I cannot see most of the level. I’ve included parts of the code below. Thanks, Phil

     

    import Felgo 3.0
    import QtQuick 2.0
    import "../common" as Common
    
    Common.LevelBase {
        levelName: "mygameMenuScene"
    
        MygameGameScene {
            id: mygameGameScene
            onGameOver: menuWindow.show()
            width: 320
            height: 480
        }
    
        Item {
            id: menuWindow
    
            width: parent.width
            height: parent.height
    
            //...
        }
    }
    

    MygameGameScene.qml:

    import Felgo 3.0
    import QtQuick 2.0
    import "../common" as Common
    
    Scene {
        id: mygameGameScene
    
        signal gameOver()
        enabled: false
    
        //...
    }

     

    #11322

    Phil

    The code from MultiSceneMultiLevel is:

    Main.qml

    import Felgo 3.0
    import QtQuick 2.0
    import "scenes"
    
    GameWindow {
        id: window
        width: 320
        height: 480
    
        //...
    
        // game scene to play a level
        GameScene {
            id: gameScene
            width:320
            height:320*window.height/window.width
        }
    
        //...
    }

    GameScene.qml

    import Felgo 3.0
    import QtQuick 2.0
    import "../common"
    import "../levels"
    
    SceneBase {
        id:gameScene
        focus: true
    
        //...
    
        // load levels at runtime
        Loader {
            id: loader
            source: activeLevelFileName != "" ? "../levels/" + activeLevelFileName : ""
            onLoaded: {
                // since we did not define a width and height in the level item itself, we are doing it here
                item.width = parent.width
                item.height = parent.height
    
                //...
            }
        }
    }

     

    #11330

    Günther
    Felgo Team

    Hi Phil!

    The Scene component is responsible for scaling the elements of the scene to the actual resolution of the device. So no matter the device, the scene along with its elements always fit the screen.

    As far as I see it, you currently create a structure where multiple scenes are used.
    (GameWindow -> Scene (GameScene) -> Loader (loads your level) -> MyGamegameScene (Scene within your level)

    As both scenes try to scale their contents to match the device window, things get messed up at this point.
    Just try to build your Levels in a way that doesn’t use an additional scene and you should be good to go. 😉

    Best,
    Günther

    • This reply was modified 8 years, 5 months ago by  GT.
    #11364

    Phil

    Thanks! That makes sense. I replaced the ‘Scene’ in MygameGameScene.qml with ‘Item’ and now it’s working fine.

Viewing 4 posts - 1 through 4 (of 4 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