Automatically Layout-Resize

For questions about using Classic.

Post » Tue May 13, 2008 12:28 am

I take a Layout with a size of 1024x768 and want to let the user resize it to 1280x1024 and above. Can I do this via the "System:Set Layout size to" and/or "System:Change Display size to"-Events without the need to reposition every sprite to it's X/Y-value?

Elsewhere you always have a very long Event-List to position the sprites:

e.g. for a fullsize background image it will result in four lines of code for one object! :shock:

[code:xygy28os]
Sprite: Set width to 1280
Sprite: Set height to 1024
Sprite: Set X to 640 (Width/2)
Sprite: Set X to 512 (Height/2)
[/code:xygy28os]

Or is there an other solution for this problem :?:

I hoped that the "System:Change Display size to"-Event would do the resize, but it doesn't. :cry:
B
2
G
4
Posts: 11
Reputation: 1,072

Post » Tue May 13, 2008 4:06 am

In my opinion, you should take advantage of layer zooms. Build your game around a certain resolution and aspect, and then zoom your layouts using that as a base.

In pseudo code:

[code:179ejxv1]OriginalX == 640
OriginalY == 480
CurrentX == ?
CurrentY == ?
Set X Zoom factor to:
(CurrentX * 100) / OriginalX
Set Y Zoom factor to:
(CurrentY * 100) / OriginalY[/code:179ejxv1]

This is a simple ratio thing I learned in high school. It produces a percentage of scale (with OriginalXY being 100%) that will always correctly scale your layers to any resolution in the same aspect ratio.

EDIT: I should point out if you plan on letting your game scale to high resolutions, you should create all your graphics at as high a resolution as possible and scale them down in Construct. Thus, when you zoom your layers you do not encounter blurry sprites and backgrounds.
B
3
S
2
G
4
Posts: 310
Reputation: 2,120

Post » Tue May 13, 2008 8:52 am

In any resizable game I've developed, I've always just positioned everything relative to the window, ie. using the expressions ScrollXLeft, ScrollXRight, ScrollYTop, ScrollYBottom (and DisplayWidth, DisplayHeight). This way, no matter what you resize the window to, the objects automatically position themselves relative to the window.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Tue May 13, 2008 1:18 pm

Relative-to-the-window is great, but it doesn't solve everything. If you wanted to scale your game to 1080p, for instance, proportional zooming is a better choice as it avoids making your graphics too small to see.
B
3
S
2
G
4
Posts: 310
Reputation: 2,120

Post » Tue May 13, 2008 1:54 pm

[quote="CaptainOblivious":x8ei0cxv]Relative-to-the-window is great, but it doesn't solve everything. If you wanted to scale your game to 1080p, for instance, proportional zooming is a better choice as it avoids making your graphics too small to see.[/quote:x8ei0cxv]

Zoom is a good thing to work with if you use it for 3D, but how would you zoom the layout if you just use it for the GUI and you didn't want to let the user scroll the GUI-Window or have large buttons?

[quote="Ashley":x8ei0cxv]In any resizable game I've developed, I've always just positioned everything relative to the window, ie. using the expressions ScrollXLeft, ScrollXRight, ScrollYTop, ScrollYBottom (and DisplayWidth, DisplayHeight). This way, no matter what you resize the window to, the objects automatically position themselves relative to the window.[/quote:x8ei0cxv]

Yepp, that's what I've mentioned above! Positioning the sprites relative to the original position! I've just wanted to know if there is an automatic function for it in Construct (like auto-positioning)?

@BUGREPORT:
[code:x8ei0cxv]
Function:
SystemSet Layer 1 zoom offset to (1, 0.0)
[/code:x8ei0cxv]

This function kill the Debug-Window with an unhandeld error!
B
2
G
4
Posts: 11
Reputation: 1,072


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests