UI positioning on a zoomed layout

For questions about using Classic.

Post » Wed Oct 06, 2010 5:25 am

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.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed Oct 06, 2010 10:02 am

Is that with display zoom, or layer zoom?
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed Oct 06, 2010 11:05 pm

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.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed Oct 06, 2010 11:15 pm

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?
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed Oct 06, 2010 11:31 pm

I was actually using unbound scrolling :P
Using bound scrolling works, but what if your game needs unbound scrolling :P
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 :P
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Wed Oct 06, 2010 11:47 pm

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 :D
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests