0 Favourites

UI positioning on a zoomed layout

This forum is currently in read-only mode.
  • Hello!

    I haven't given up yet but this is driving me nuts right now (arrrrr)

    Try this for yourself:

    -Make a layout larger than your window.

    -Create a new layer with 0% scroll rate. (place sprites on both layers so you can see something!)

    -Set an event to halve the window size and set zoom to 50 on both axes.

    You should now see that while you can scroll around the base layer normally (you can use center-on-me attribute on an 8-direction sprite to test it), the layer with 0% scroll rate will be static as expected, but it will appear displaced. This is because the zoom happens around the center of the layout, while the coordinates of objects have a center on the upper left corner of the layout.

    The solution is to displace every object in the 0% scroll rate layer on startup. How much to displace them?

    That's what I'm having trouble finding out. What if the zoom is not 50 but something else?

    I'm trying to arrive at an expression to get this, but it still eludes me. I must be overlooking something.

  • Is that with display zoom, or layer zoom?

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • With Display zoom, but I guess it could be any.

    I want to keep the zoom, so setting 0% zoom on the layer is not a solution.

  • I guess you could try it with unbound scrolling, and see if that helps... but I doubt it.

    Only other thing might be an fx, but you know how that would go.

    I have seen the offset before, but I thought that was just on the dx widgets.

    Any way I'm out of buts.

    Make a bug report, and see what happens?

  • I was actually using unbound scrolling

    Using bound scrolling works, but what if your game needs unbound scrolling

    Also, I believe it only works if you're zooming out. If you're zooming in, the 0% scrolling layer would move towards the center, which is within the layout bounds.

    It's not exactly a bug per se... it's a consequence of zooming from an origin different to the positioning origin... I'd like to pick the origin for both per layer anyway

  • What I did try was:

    -Get the layer's origin (upper left corner) in the layout's center frame of reference (LayoutWidth/-2 , LayoutHeight/-2)

    -Scale that position according to zoom (0.01*ZoomX*LayoutWidth/-2 , 0.01*ZoomY*LayoutHeight/-2)

    -get the scaled position in the frame of reference of the layer ((0.01*ZoomX*LayoutWidth/-2)+(LayoutWidth/2) , (0.01*ZoomY*LayoutHeight/-2)+(LayoutHeight/2))

    It worked somewhat, but it overshoots... There's a factor I'm missing on Construct's zoom . It seems that zooming doesn't ..... wait.

    I might have it. Will edit this soon.

    EDIT: Got it!!!

    Since scroll rate is zero, it's zooming around the center of the SCREEN, not the layout. So scrolling rate affects zoom. Go figure. Replace LayoutWidth/Height with Display and it works

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