Viewport not centered in browser

0 favourites
  • 5 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • 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!

    SETTINGS

    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.

  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • NEW DEVELOPMENT

    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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)