[Obsolete] Perfect 1:1 Window Scaling

This forum is currently in read-only mode.
0 favourites
From the Asset Store
Pack of illustrator graphic styles. Make your own logos, game titles, or anything you want.
  • This is now an obsolete topic. Recent changes in Construct Classic have solved this problem. Perfect window scaling is possible by simply changing the client width and height.

    For your convenience, this is copy/pasted in the .cap

    The problem with 1:1 window resizing is that DisplayWidth/Height return the actual resolution of the window while Window.Width/Height return the resolution of the window + the window handle (You know, the border and the thing with the x on it!).

    Notice at the bottom of the layout the fact that the window size is NOT a multiple of 128x128 like it should be. This is how Window.Width/Height measures it. This includes the windows handle/border.

    To use the Window: Set Width action, we must determine the width and the height of the border and add it to the multiplied DisplayWidth/Height AFTER we multiply it to scale the screen. If we don't, the game is slight stretched out of proportion. You probably won't notice this on a regular game, but on a retro/pixel game, it's ever-so-obvious that something is wrong.

    Also, as a limited time offer, I show you how to properly center the screen after a window resize! Megaman included for example, and for awesomeness.

    Good luck with your games!

    Love,

    greyspot

    Created in Construct 0.99.91.

    Opps, updated the .cap

    Combined silly things like "set x" and "set y" to "set position." Same with width and height to size.

  • you can circumvent the whole border problem by disabling captions, then it has no border to measure and returns the size you put properly, as youd normally expect.

  • Did this a while back.

  • Hey, have you looked closely at Window object? David added some features to it, such as ClientWidth and ClientHeight, which is the actual viewable area without borders and stuff.

  • First of all thanks greyspot for trying to nail this... I'm looking for something like this for quite a while.

    But... your formula seems to have a problem.. Althought aparently it's scaling correctly, infact the aspect ratio isn't being maintained. The image below show's how when doubled or tripled the window actually adds random vertical and horizontal rows of pixels, thus distorting it.

    <img src="http://img841.imageshack.us/img841/3320/greyspotaspectratio.png">

    As you can see marked in the left image with a red line there's an extra row of pixels added with the doubling method. I really wish there was a simple and effective way to scale pixel perfect an app in Construct, with or without captions.

  • did you even read mipey's post -_-

  • Craaaap. I though I had it that time. I didn't even notice :/

    did you even read mipey's post -_-

    I still have that .cap in my "examples" folder :D

    I did this because it wasn't quite right for my needs.

    Mainly:

    1. Doesn't work any more. Could edit it, but meh.

    2. Even though I totally left that out, this was meant to work with window borders. It's a lot easier without window borders. I can't tell you how much I hate it when a game has no window border, unless it is fullscreen of course. I can't reposition it, minimize it for a minute, or close it easily without going through stupid in-game menus (assuming Alt+F4 doesn't work). Sure, I got the task bar, but c'mon now...

    Oh well, back to the drawing board, as I fail at more community contributions D:

  • Sometimes it is better to start anew and try new approach as new features are made available. If I have time, I'll whip a fresh example together.

    If I don't forget to.

  • So, uhm, I'm having a problem, and I feel that it's pretty serious.

    I was attempting to do window scaling for my pixel game. I wanted to give the user the option to play in a regular window(320x320) or a doubled window(640x640), for those who like to see everything at 2x size. However, no matter how many times I tried, my results turned out blurry as heck. It seemed that regardless of whether I chose point sampling or linear sampling, I had the same results. I had thought that what I was trying to do was a very simple thing. I was just setting the client height and width to double what they already were.

    So, in effort to solve my problem, I checked this post. The first thing I did was take a look at the Megaman example provided. However, when I opened it, and tried the enlarged settings, they looked blurry as well. At this point, I became quite confused.

    It seems to me that point sampling does not work on my computer or something. To me, linear and point sampling look exactly the same, regardless of whether I'm viewing my .cap or the one provided in this post. Point sampling appears blurry, just as linear.

    I consulted the IRC channel, and someone using a dual monitor set up tried my .cap. According to him, when he moved the window to one screen, point sampling worked. However, when he moved the window to his opposite screen, it no longer worked(as if one screen was using point and the other was using linear). This, to me, was even more confusing.

    My conclusion is just that point sampling is broken.

    Here, is a screencap of a tile scaled to double size in paint(right), and one scaled to double size using point sampling in construct(left). As you can see, point sampling is blurry.

    <img src="http://i32.tinypic.com/2yjwzrq.png">

    And lastly, here is the .cap of my project, set to point sampling. On my screen it appears blurry when the client is doubled(press Z). But, on your screen, it may appear correct, I really am not sure.

    http://www.2shared.com/file/83D0GEoO/Juice.html

    (Note that in order to downlaod the .cap on that page, you must scroll to the bottom and find "click here." Otherwise, you'll end up downloading a toolbar, or a robot dancing to Miley Cirus.)

    If any additional details or screencaps are needed, please let me know.

    Thanks in advance.

  • Silhouette

    The burring is due to how your graphics driver resizes windows.

    Here is a way to have 2:1 scaling without any filtering:

    * Check "unbounded scrolling" in the layout properties.

    Then run these actions:

    -> System: Set Zoom to (200, 200)
    -> System: Set layout size to 640 x 640
    -> System: Change display size to 640 x 640
    -> System: Scroll to X 0
    -> System: Scroll to Y 0[/code:1bbuufdj]
  • Hey, thanks for the reply. And thank you so much for the fix. Just so I can be sure though, on some computers, a simple client*2 would work, and it's just in my case that I need to resize like this, correct?

  • It looks like it doesn't matter if your display size stays in proportion or anything. Even if I go from 128x128 to 256x256, Construct arbitrarily stretches a line of the sprite horizontally or vertically.

    Oh well, I suppose that it works well enough for now. I think that this would be much easier if we could set client width/height as easily as we could get the value for it! Or maybe an action to toggle the window handle on and off. Then I wouldn't have had to do all that silly stuff to get the border size from the window!

  • I got a HUD layer and when i zoom it in it goes offscreen, any ideas on how to place it properly?

  • I got a HUD layer and when i zoom it in it goes offscreen, any ideas on how to place it properly?

    you may set zoom rate to 0% in the HUD layer along with 0% scroll rate.

    Unless you wanted the HUD to zoom along, in which case you're in the same place I am

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yeah i wanted it to zoom along with everything. Guess i'll just make a scaled up sprite

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