Find the Best Demos and Examples

Check out this quick tour to find the best demos and examples for you, and to see how the Felgo SDK can help you to develop your next app or game!

Forums

OverviewFelgo 1 Support › position of objects with different aspect ratios

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4559

    hener.stephan

    hey,

    i am currently having problems with the position of objects with different aspect ratios,

    lets take for example i want to place a rectangle and the top left of the screen:

    import VPlay 1.0
    import QtQuick 1.1
    
    GameWindow {
        activeScene: scene
    
        width: 640
        height: 960
        
        Scene {
            id: scene
    
            width: 320
            height: 480
    
            Rectangle {
            width:50
            height:50
            color: "red"
            x:0
            y:0
            }
    
        }
    }
    
    

    the result is this for different aspect ratios:

    https://i.imgur.com/23CpPiY.png

    in the second picture the rectangle isn’t in the top right,

    i presume it’s because how vplay handles different aspect ratios,

    but is there a way to have it at the same position regardless of the aspect ratio?

     

    cheers

    stephan

     

     

     

     

    #4563

    Christian
    Felgo Team

    Hi Stephan,

    yes there is a way: where the Scene is placed in the (possibly bigger) GameWindow, depends on the sceneAlignmentX and sceneAlignmentY properties. By default, they are set to center which is why your logical scene is put in the center, when the GameWindow is bigger. If you want to position you scene always to the top, you can set sceneAlignmentY to “top”. If you want to position elements in the scene always relative to the GameWindow, use the gameWindowAnchorItem for that, as we have done it in our sample games.

    Cheers, Chris

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.