How do I Keep UI objects centered in a "Scale Inner" Project

0 favourites
  • 12 posts
From the Asset Store
With this template you can create your own archer game and customize it however you want.
  • I'm talking about keeping something in the middle of the screen at the top or bottom or keeping things in the corner to resize with the view size. For some reason scale inner is throwing everything way off, and I've tried viewport, window, scrollx, but I just can't keep an object in the center on the UI at different sizes. Any ideas? Thanks.

  • every tick

    Object set position

    X: (ViewportRight("UI") - ViewportLeft("UI")) / 2

    Y: (ViewportBottom("UI") - ViewportTop("UI")) / 2

  • every tick

    Object set position

    X: (ViewportRight("UI") - ViewportLeft("UI")) / 2

    Y: (ViewportBottom("UI") - ViewportTop("UI")) / 2

    Thanks for the suggestion, but it looks like that didn't work either. I should note the element is on a 0,0 parallax layer, without an anchor, but I tried in a 100,100 as well. The element I'm trying to center is the White UI box.

    Here's screenshots from both of my monitors, at neither resolution did it center. <img src="{SMILIES_PATH}/icon_cry.gif" alt=":cry:" title="Crying or Very Sad">

    http://puu.sh/iNGL8/15fbf6bf0c.png

    http://puu.sh/iNGM0/afb5b1afd0.png

  • > every tick

    >

    > Object set position

    > X: (ViewportRight("UI") - ViewportLeft("UI")) / 2

    > Y: (ViewportBottom("UI") - ViewportTop("UI")) / 2

    >

    Thanks for the suggestion, but it looks like that didn't work either. I should note the element is on a 0,0 parallax layer, without an anchor, but I tried in a 100,100 as well. The element I'm trying to center is the White UI box.

    Here's screenshots from both of my monitors, at neither resolution did it center. <img src="{SMILIES_PATH}/icon_cry.gif" alt=":cry:" title="Crying or Very Sad">

    http://puu.sh/iNGL8/15fbf6bf0c.png

    http://puu.sh/iNGM0/afb5b1afd0.png

    Does the image have its origin point in the center ?

  • >

    > > every tick

    > >

    > > Object set position

    > > X: (ViewportRight("UI") - ViewportLeft("UI")) / 2

    > > Y: (ViewportBottom("UI") - ViewportTop("UI")) / 2

    > >

    >

    > Thanks for the suggestion, but it looks like that didn't work either. I should note the element is on a 0,0 parallax layer, without an anchor, but I tried in a 100,100 as well. The element I'm trying to center is the White UI box.

    >

    > Here's screenshots from both of my monitors, at neither resolution did it center. <img src="{SMILIES_PATH}/icon_cry.gif" alt=":cry:" title="Crying or Very Sad">

    >

    > http://puu.sh/iNGL8/15fbf6bf0c.png

    > http://puu.sh/iNGM0/afb5b1afd0.png

    >

    Does the image have its origin point in the center ?

    It does, I just double checked.

  • Well, could be I'm missing something with Scale inner.

    I generally apply that with scale outer, not really a fan of scale inner, as you can miss pieces of the layout

  • Well, could be I'm missing something with Scale inner.

    I generally apply that with scale outer, not really a fan of scale inner, as you can miss pieces of the layout

    Scale inner was giving me a headache, so I'm willing to switch to scale outer. However, even after doing that something is off. I keep double checking everything and I can't imagine why it won't work.

    http://puu.sh/iOd3U/47e431f673.png

    http://puu.sh/iOd4u/fed5394878.png

    Here's the .capx: https://dl.dropboxusercontent.com/u/441 ... redUI.capx

  • Something fishy going on there with the fullscreen mode >_>

    If I have my window maxed, its off in the center ....

    If I make my window smaller / not maxed, the centering works as expected.

    I can't put my finger on it whats causing it.

  • lennaert Yeah there definitely is, maybe it's a bug? Hopefully someone can figure this out.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Bump.

    Any ideas Ashley ?

    I'll re-post this to the bugs section if no one is able to figure it out, because I can't see I'm doing anything wrong.

  • lennaert forgot something..

    It was almost correct..

    Object set position

    X: VieportLeft("UI")+(ViewportRight("UI") - ViewportLeft("UI")) / 2

    Y: ViewportTop("UI")+(ViewportBottom("UI") - ViewportTop("UI")) / 2

  • It should be a simple matter of setting it to the middle of the viewport as the posts in this thread already suggest. Check the origin is in the middle. If it doesn't work please post a minimal .capx with nothing else in it other than the object, with 50 events and lots of objects it's hard to prove it's not something else you've done that is breaking it.

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