[Solved] window size 1920x1080 landscape

0 favourites
  • 5 posts
From the Asset Store
Get Ready for the New Wave of "Bottom Screen" Games!
  • Problem Description

    i created a new empty template, changed the resolution for the layouts to 1920x1080 and the template screen till here all good, until i create a sprite and try to automatically place it on start in the center of the screen based on the window.height/2... window.width /2 ... as simple it sounds... there is a displacement... not sure if this is because of the browsers or not but problem persists on chrome, firefox, internet explorer and even NW.js

    the capx also includes 2 other sprites i used to determine the actual WindowHeight WindowWidth center...

    also another note : i tried another test placing the object to the center of the screen by first taking the ViewportRight("0") then subtracting WindowWidth/2 of the curent position.

    it seems instead of - the system does a +

    for that i have no capx .

    since the method is a bit unusual and i just need the WindowWight WindowHeight expression to work for my capx.

    Attach a Capx

    ____ Upload a Capx to this post ____

    Description of Capx

    ____ Concise description of what this CapX does ____

    the capx is a new empty template, that has 2 lines of codes to automatically position a newly created sprite.object based on WindowHeight/2 WindowWidth/2 system expressions.

    Steps to Reproduce Bug

    • Step 1 create a new empty template
    • Step 2 set the resolution or screen size to template and layout to 1920 width 1080 height
    • Step 3 create a new sprite object
    • Step 4 set the position of the new created sprite object using the set_position expression to x:WindowWidth/2 y: WindowHeight/2

    Observed Result

    on my testing i added a text object to get the WindowWidth and WindowHeight and the valuesof WindowWidth and WindowHeight divided by 2.

    it seems the windowHeight is not 1920 x1080 but 1644 x 925 .

    Image reference

    Expected Result

    sprite to be positioned to the exact center of the screen that is initially set ie. 1920x1080

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)
    • Internet Explorer: (YES)
    • NW.js: (YES)

    Operating System and Service Pack

    Win8.1 Enterprise N x64 bit

    Construct 2 Version ID

    ____ r227 stable 64-bit version ____

  • - I noticed that before when I was making a .capx to help in the forum. But I believe that is not a bug because the Window Width and Window Height is based on the browser's size or screen size(if fullscreen). You should use "OriginalWindowWidth" & "OriginalWindowHeight" for that to have an accurate measurement.

    Edit: I also found something that worsen the inaccuracy with the positioning of your test-sprite. I noticed when I replaced the "WindowWidth" and "WindowHeight" with "OriginalWindowWidth" & "OriginalWindowHeight" that the position of the sprites are still misplaced, that's when I noticed that the image size is (5,5) and when I set the image point to middle the image point goes to (X:2.5,Y:2.5) but when I close the image editor and reopen, I saw that the location came to (X:3,Y:3) and it looks like it rounded it off and it will make problems with positioning. I don't know if the image points inaccuracy is a bug but for the moment I suggest using TiledBackgrounds or resize the image of the sprites to numbers that can be divided and still retain a whole number.

  • - I remade your .capx here. I hope it helps. https://onedrive.live.com/redir?resid=A ... ile%2ccapx

    BTW Ashley is it a bug that the imagepoint X,Y rounds up decimal numbers?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • - I remade your .capx here. I hope it helps. https://onedrive.live.com/redir?resid=A ... ile%2ccapx

    Thanks ,it does work now, however last time when i tried to do the same thing i did not used OriginalWindowHeight expression... did it got changed in the latest updates?

    i noticed also the rounding of the image-point but didn't thinked wold be a possible bug.

    however based on what you said ....

    I believe that is not a bug because the Window Width and Window Height is based on the browser's size or screen size(if fullscreen)

    my res by default is 1680x 1050 so now makes sense why it wold do that ... but it wasn't doing it on the low spec monitor i had before a 1280x1024 max res one.

    ... now i feel dummy ...

  • Closing as not a bug, you are using the wrong expressions. To center something in the viewport, use (ViewportLeft("layer") + ViewportRight("layer")) / 2, (ViewportTop("layer") + ViewportBottom("layer")) / 2.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)