How do I crop the game until integer scale is possible?

0 favourites
  • 7 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • Hello,

    I've got an interesting task that I need some help with.

    I need to keep my game pixel perfect, so Integer Scaling works nicely for that. However I am trying to make it so that it doesn't pop immediately to the next multiple down showing large black bars, but instead will crop the game until that next integer multiple is possible, and THEN it will pop to that scale, and continue the cropping. This way there are no black bars, and it will only be cropped if the window is off-aspect.

    Is this possible? I'm struggling to figure out how I might be able to do this by manipulating the camera using the WindowHeight and WindowWidth, but it hasn't been very successful yet.

    Any suggestions are welcome.

  • Found some moderate success using the Crop fullscreen mode, along side Magicam to set the layout zoom on tick based on "round(WindowWidth / GameWidth)", while also keeping the player centered.

  • Found some moderate success using the Crop fullscreen mode, along side Magicam to set the layout zoom on tick based on "round(WindowWidth / GameWidth)", while also keeping the player centered.

    I'm trying to figure out how to use crop instead of integer and keep my pixels square instead of some of them going into rectangles. Someone else mentioned using the scale integer divided by browser.DevicePixelRatio but this didn't work for me. I'm using Magicam also, and I want to use 1920x1080 screen size, but scale using Magicam. This way I should be able to use subpixels for smooth motion, without having pixels resized badly. DId this method work okay for you?

  • Found some moderate success using the Crop fullscreen mode, along side Magicam to set the layout zoom on tick based on "round(WindowWidth / GameWidth)", while also keeping the player centered.

    Also, what project settings did you use?

  • A scale outer integer mode has been asked for before. It would be a great addition so essentialy it would scale to the next integer size outside the window instead of inside as we have it now. Nothing has come of this request though.

  • A scale outer integer mode has been asked for before. It would be a great addition so essentialy it would scale to the next integer size outside the window instead of inside as we have it now. Nothing has come of this request though.

    I mean, I'd be happy enough if I could keep the smooth scrolling AND actually have the game upscale the pixels properly on integer mode, but it doesn't work on high quality scale mode at all, they get distorted.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • A scale outer integer mode has been asked for before. It would be a great addition so essentialy it would scale to the next integer size outside the window instead of inside as we have it now. Nothing has come of this request though.

    Yes that's more precisely the effect I was searching for. I'm happy to see I'm not the only one trying to do this, and that it actually has a name. Too bad it's gone unimplemented.

    > Found some moderate success using the Crop fullscreen mode, along side Magicam to set the layout zoom on tick based on "round(WindowWidth / GameWidth)", while also keeping the player centered.

    >

    Also, what project settings did you use?

    Basically I've got my Magicam setting zoom based on the size of the window. Anytime the width or height surpasses a multiple of the true game resolution, the zoom increases by 1.

    So if your game is 100 pixels wide, and your window is stretched to 530 pixels wide, it would be zoom = round(530 / 100), which would result in the camera being zoomed to 5x normal. As long as you keep your zoom at integer values, your pixels will stay square. I then have my project's mode set to Crop. I can give you more details once I'm home, but that's really the gist of it.

    I believe I take (windowWidth / nativeWidth) and then compare it to (windowHeight / nativeHeight). Which ever is bigger is what I use as the new zoom. I may do some shenanigans involving checking if the current platform is mobile for some small-format changes, but not much else.

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