Black bars and zoom to any resolution/AR

This forum is currently in read-only mode.
  • [UPDATE: ZOOM WORKS PROPERLY NOW, ALWAYS!]

    This example shows how to zoom any game layer to match a new resolution, adding black bars wherever needed.

    Set the globals and watch the magicks. The object placement relative to corners will match in design and runtime, even if you change resolution or switch to fullscreen. Stretching will preserve design-time proportions. Feel free to change the design-time window size, there's an event that changes the resolution in runtime (layout1 events, has to run before the resolution event sheet) and you may toggle it or change it. Feel free to try fullscreen, etc.

    Watch how the objects placement will match the runtime placement, provided you set the right values in the following global variables:

    WARw, WARh: Window Aspect Ratio (width, height). If windowed, this has to match the window. If fullscreen, this should match the monitor. Popular sizes are 4:3, 16:10 and 16:9

    DRw, DRh: Design Resolution (width, height). This is your target, it stays the same for the whole game no matter the current display as you design the game in that size. It assumes square pixels during design, which is the norm in desktop PCs (and Construct IDE will assume the same anyway, so it'll still match if you have something different).

    yes, using a windowed game should always yield no bars, as you can see. Zooming may apply though.

    used .9994

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks madster for this amazing useable example

    It gave me a headache to make a game working in every resolution, especially if you design in 4:3

    and want to show it good too in 16:10 and 16:9

    This is a good start for everyone that wants to make a serious game that works in every resolution.

    Keep up the good work

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