Strech Canvas

Get help using Construct 2

Post » Thu Apr 05, 2012 2:14 pm

Is there a way to stretch the canvas to fill the whole window?
Instead of scaling/cropping.
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Thu Apr 05, 2012 3:17 pm

So instead of "Fullscreen scale" mode, you want... a non-proportional stretch which will distort it wider/taller?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Thu Apr 05, 2012 3:26 pm

@Ashley
Yes! I know it sounds crazy, but I want to test for iOS if I can stretch from iPhone to iPad as the difference in width is not much.

How can I do it? I tried searching in the html5 exporter for the function you use but I can't find it anywhere, it's the last piece I need to publish on the appstore.

Thank you!
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Thu Apr 05, 2012 3:28 pm

We don't actually support this... I think your best bet is to go with the fullscreen scale mode! It's actually a little trickier than you might think because an important part of the engine is converting screen co-ordinates to layout co-ordinates and back again, and for various reasons the math only supports a single scale value, not different scale values on the X and Y axes.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Thu Apr 05, 2012 4:49 pm

@Ashley. Then you might have a problem. In my application (which has fixed elements) the resizing on the iPad destroys everything, meaning that the sprites leave a trail to the left size of the screen! Not only that, but the resizing creates problem with the injection of a new sprite (which is not your fault since it's a plugin but still).. is it possible then to have a conditional statement to change between crop and scale inside the code? To avoid building two times..
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Thu Apr 05, 2012 7:34 pm

@0plus1 - try setting the 'Clear background' project property to 'Yes' to fix trailing backgrounds.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Thu Apr 05, 2012 7:42 pm

@Ashley I'll try that, but my main problem is the ugly white column, so far I have two solution, for both I need your imput.

1) Change the layout size as an action, I didn't see a way to do this, but maybe there is. If there isn't is it possible to do this with a plugin? What I mean is I have a layout that has a property of 100x100 I change it at runtime to 200x200.
2) If the previous is not possible I could create two or more layouts in order to have different aspect ratios, but! Is the Window Size property a constraint? Or is it only used for the initial canvas size (before resizing)?
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Thu Apr 05, 2012 7:52 pm

There's no need to change the layout size, just set 'Unbounded scrolling' to 'Yes' and you get an infinite layout area.

You should be able to fairly straightforwardly support multiple aspect ratios from one project. I added a new section in supporting multiple screen sizes recently which covers it.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Thu Apr 05, 2012 11:10 pm

@Ashley thanks, this is really interesting.
So I could stretch the background based on the WindowHeight and Width properties myself and position all objects to the center of the screen and I would be done.

Still there is another small issue, on the iPad everytime you change layout with scale mode the layout starts in the center and then goes to the left side leaving a trail, you already told me about clear background (which also impacts performance as shown in another tutorial). If I set the unbounded scrolling what happens then?
To me it looks like this will happen:
c2 still has the aspect ratio of 1.5 (iPhone). The layout loads, the canvas get resized, only this time the background covers everything (I imagine this happens BEFORE any of my actions) then I reposition my objects and I would have a "simulation" of native resolution, is this right? But the ghosting will still happen without setting the clear background right? DId I got this right?

If this is the case this is really genious and you are one of the few frameworks that can support multiple aspect ratios out of the box!

If I'll ever be able to finish my app I'll write a detailed tutorial on making apps for iOS because there are several issues to get around to and most of them require messing with the code.
B
29
S
9
G
6
Posts: 525
Reputation: 8,294


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests