How do I make the layout and window size match?

1 favourites
  • 11 posts
From the Asset Store
Get Ready for the New Wave of "Bottom Screen" Games!
  • Hi Everyone,

    This is something I have struggled with mightily, and hoping you can help.

    I do not understand all the display settings and how that equals what the actual game view is. For some reason if I leave the Full screen option enabled, each time I run the game the window gets smaller and smaller until it eventually resets and starts over.

    But if I don't run full screen the bottom and right edges get cut off by the window size (even though they are both set to the same size).

    Tips, hints or tricks are welcome for how to fix this. (eventually I would like my game to have windowed and full screen options.

  • Will need to see your project to troubleshoot. I'm guessing you have some event running every tick that shouldn't be.

  • Here you go: drive.google.com/open

    But I have had this issue with every project I have started.

  • click on the very first folder and in the properties window about 20 fields down it says "viewport size" make that match your layout size and viola.

  • Nope, no change. Already did that.

  • I've always had issues with the viewport/screen width. The only way I've come up with that somewhat solves the issue for me is this:

    Create a function in a an event sheet that you can add to other event sheets. Call it: "ResizeLayout"

    In that function call a: System - set canvas size

    Set the canvas size to:

    Width: Browser.ExecJS("window.innerWidth")

    Height:Browser.ExecJS("window.innerHeight")

    In the same event sheet create an event: Browser - On resized

    have it's event set to: function: Call "ResizeLayout"

    In the System - start of layout

    On all of my event sheets (the ones that have a layout) I also have it call that ResizeLayout function.

    If you use a mouse click to select and cancel the full screen browser, run that function after you request or cancel the full screen.

    I've used it with several full screen modes and it even works with the mode set to off.

    Or at least it does for me.

    Now, here's the downside to this. When your layout loads or when the screen gets resized your objects on the layout may not place correctly. I solve this by manually setting the position of every on-screen object after that function is called in the On start of layout.

    Here's an example of placing an element at the screen center:

    x = viewportleft(0)+(viewportwidth(0)/2)-(element.width/2)

    y = viewporttop(0)+(viewportheight(0)/2)-(element.height/2)

    That's assuming the element anchor is in the top left.

    This may not be the 'proper' way and it may or may not work for your game. Most of my objects are static but... hope this at least gives you some ideas.

  • So are we saying the built in functionality is broken?

  • Basically there is no built in functionality to get the current window size. The intention is use best practice scaling modes to support different aspect ratios, since you have no control over the window size of the end user. There shouldn't be any case where resizing your visible viewport to whatever the window size is is superior (this would basically be like using a huge viewport, and no scale mode.

    This article may help, in case you haven't seen it yet. construct.net/en/tutorials/supporting-multiple-screen-17

  • Thank you for the link, that helped some in explaining what setting does. And I fine with their being black bars and all that. But what I can't stand when using the full screen option is that it slowly makes the window smaller with each launch without any changes from me.

    If you can tell me why it does that and how to fix it, I will be eternally grateful.

  • Gadgetkk

    that could be a browser issue... trying to cascade the windows or something.

    if you maximize the preview window, it should always look the same.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So I usually do this chrome just because it has the desktop launcher, so that is the browser where the window keeps shrinking.

    I tested it in Firefox (my normal browser of choice) and it doesn't do it. So it is the browser.

    Is there a way to do a desktop launch in Firefox like there is in chrome?

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