Viewport not centered in browser

Get help using Construct 2

Post » Sun Mar 10, 2013 8:44 am

Just purchased Construct2 and am learning to program at a rather late stage in my life. I even managed to incorporate touch scrolling, following the advice in those most helpful Construct2 tutorials.
So far, so good, except for a small problem. After days of searching and experimenting with settings, I've reached a dead end.
My app is for deployment on mobile devices, only in portrait mode.
It mostly contains instructional text, spread across different layout screens - Step 1, with an explanation and example. Step 2, with explanation and an example, and so on.
When I preview the app on the iPhone, iPad, Galaxy Tab 2 and the Galaxy S3, the viewport displays left-aligned, so the blocks of text all appear offset to the left of the screen, leaving a white background on the right side. I want the text centered.

Is there something wrong with my "Browser" settings?

Please help. Desperate!

Window size: 768 x 1366.
Margins: 10, 10.
Fullscreen in Browser: Scale.
Layout 1 Size: 768 x 1366.
Layout 1 Event: Browser | (Condition) Is Fullscreen | (Action) Browser | Request fullscreen - Centered.
Posts: 3
Reputation: 681

Post » Sun Mar 10, 2013 8:35 pm

Might not be the answer you're looking for, but I posted about this the other day and didn't get a response, so I'm not 100% sure why, but I also found that the viewport settings were off-centre by quite some way.

It was really strange because my main arcade screen is centred perfectly and I just use WindowWidth and WindowHeight to find positions, but that doesn't work on a new screen. Then I found that I had a sprite that had the 'Scroll To' behaviour applied, so I added that to my new screen and suddenly it all seemed centred properly. Try adding an off-screen sprite with 'Scroll To' behaviour, then you'll find if you put an object at 0,0, it appears at the top left.

I still don't understand what's going on here but it works. My screens are now perfectly centred, but as soon as I remove that sprite, I have the same problem.

*I should point out that there's probably a 'proper' way to do this. If you do ViewPortLeft-ViewPortRight you do actually get the centre of the screen. I just found that very hard to work with as it means I need to do that math every time I wanted to place an object. But I'm sure there's a correct way of doing this.farflamex2013-03-10 20:38:16
Posts: 446
Reputation: 5,633

Post » Mon Mar 11, 2013 1:25 am

Thanks farflamex,

I guess I'm still looking for the "correct" solution to this window/viewscreen alignment problem. Hopefully, someone will sort it out and then I'll let you know, too.
Posts: 3
Reputation: 681

Post » Mon Mar 11, 2013 2:41 am


If I turn on "Unbounded Scrolling" for a layout then the window/viewport display is centred instead of left-aligned.

However, while this solves the left-alignment problem, it this also permits sideways scrolling, which I don't want. I only want vertical drag scrolling, with a centred window.

All very confusing.

Posts: 3
Reputation: 681

Post » Mon Mar 11, 2013 2:34 pm

It sounds like using 'unbounded scrolling' is the right solution. If it's not enabled (and scrolling is bounded), you will probably get unwanted behavior, since the layout may be smaller than the window but scrolling is disabled so the view cannot be moved.

It should be simple to avoid horizontal scrolling: just use the 'Scroll to Y' action. Or, if you're using the 'Scroll To' behavior, only change the object's Y co-ordinate.Ashley2013-03-11 14:34:23
Scirra Founder
Posts: 22,832
Reputation: 176,700

Return to How do I....?

Who is online

Users browsing this forum: DaniellMesquito, Donskull, Laurent, Magistross, matriax, Mikhail80, Sketchy77, Yahoo [Bot] and 6 guests