Auto resize a background (not tiled)

Get help using Construct 2

Post » Tue Apr 03, 2012 6:26 pm

Hello, I'm new on the forum and a recent french user of construct 2.

I'm trying to create an application supporting multiple screen sizes with a 1920*1080 background (which is not tilable). To do so I use the scale mode of construct 2. This mode works perfectly but if the window does not have the right ratio (width/height), we can see a blank rectangle on the left or at the bottom (it depends on the ratio) of the browser window.

So y tried to resolve that by resizing the background in order to adapt it to the window in the best way (with a screen ratio based calculation on every tick). It's better but not enough.

If someone has an idea about how to do that or to correct what I made, I am listening.

Here is the capx file :
capx file vpusher2012-04-03 18:52:17
B
3
Posts: 2
Reputation: 279

Post » Wed Apr 04, 2012 4:32 pm

It's best just to draw backgrounds wider than the window size, then the normal view will just be cropped. Then if scaling up to a bigger window size the previously invisible bits become visible.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Wed Apr 04, 2012 4:44 pm

If you use On start of layout > Set (bg)Size to (WindowWidth, WindowHeight)
the background will use the window's size dimensions.

It will stretch the window in some cases, but the ratio's aren't that massive of a difference so you could resize your background to fit both ratio's.
B
22
S
11
G
9
Posts: 133
Reputation: 6,572

Post » Wed Apr 04, 2012 4:52 pm

[QUOTE=Wishy] If you use On start of layout > Set (bg)Size to (WindowWidth, WindowHeight)
the background will use the window's size dimensions.

It will stretch the window in some cases, but the ratio's aren't that massive of a difference so you could resize your background to fit both ratio's.[/QUOTE] that should work but keep in mind that the img need fo have a nice resolution to dont lose too much quality while streching..
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Thu Apr 12, 2012 8:06 pm

Thanks for all your answsers. Your proposition was interesting but not solves the problem during window resizing.

In fact, I found the solution. I just set the "unbounded scrolling" to yes and the margins to 0. And it works nice ! My calculation was right. You can test it with capx file I joined in the first post (just do the modifications in the project properties)

Thanks again.

I hope that will help.vpusher2012-04-12 20:07:08
B
3
Posts: 2
Reputation: 279

Post » Thu Apr 12, 2012 8:29 pm

You figured it out on your own. I was just going to point you to this nice example by gammabeam:

Multiple Resolutions - Solid example
B
29
S
11
G
12
Posts: 281
Reputation: 11,868


Return to How do I....?

Who is online

Users browsing this forum: blackhornet and 4 guests