Black bars and zoom to any resolution/AR

Post your own tutorials, guides and demos.

Post » Sun Sep 12, 2010 12:00 am

[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 [u:15oy86nn]before[/u:15oy86nn] 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
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Tue Dec 28, 2010 1:18 am

Thanks madster for this amazing useable example :D

It gave me a headache :oops: 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 :D
B
43
S
8
G
5
Posts: 110
Reputation: 3,605


Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 1 guest