[R103] Error setting X & Y position in crop mode

Bugs will be moved here once resolved.

Post » Tue Sep 18, 2012 7:06 pm

I want to anchor a button to the bottom center of the screen.

To set its position, I'm using:

System Every tick
   set X to windowWidth/2
   Set Y to WindowHeight-100-(spin_btn.Height/2)

The button has its origin set to the center.

The result is that the X & Y values vary widly with the screen size. E.g the longer the window, the more it disappears off below the window. The shorter the window, the more the object launches into outer space. Same with the X value. Its only actually correct when the window size happens to be the same a the window size set in the project.

Here is a 1 sprite capx file:

https://www.dropbox.com/s/gx2e1gnfn1t1uyy/middleAnchorProblem.capx

This is making life very hard...


nutmix2012-09-18 19:09:57
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Tue Sep 18, 2012 8:35 pm

Not a bug: WindowWidth and WindowHeight are not related to the viewport, so halving them does not give you the middle of the screen. Use the system viewport expressions instead, e.g. (ViewportLeft("Layer 0") + ViewportRight("Layer 0")) / 2 to get the X position of the middle of the screen.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,610

Post » Tue Sep 18, 2012 10:04 pm

Wow. That viewport stuff works, thanks. I need to draw some diagrams to get my head around it.
B
15
S
5
G
2
Posts: 357
Reputation: 3,691


Return to Closed bugs

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests