Forums

OverviewV-Play 2 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 VPlay 2.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 VPlay 2.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 VPlay 2.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 VPlay 2.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
    V-Play 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 2 years, 8 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.

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