Author Topic: Anchoring to Screen Dimensions  (Read 3780 times)

DevMan5000

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 22
    • View Profile
Anchoring to Screen Dimensions
« on: October 26, 2014, 03:00:27 PM »
Hello,

I am wondering if there is a way to anchor to screen dimensions instead of widgets in the scene.

Specifics:
UIRoot Content dimensions are 2048x1536.
Both "Fit" boxes are unchecked so clipping will occur (desired behavior).
My game layout will be landscape mode.

On the iPad (4:3), there is no clipping, on the iPhone5 (16:9) there is clipping at the top/bottom of the screen.

If I anchor a widget at 10% from the top of a 2048x1536 image, then everything is cool on iPad. However, this widget will be cutoff on iPhone5 because the UIRoot settings cause clipping on the top of the screen.

What I really would like to do is anchor my widget to the screen dimension (so 10% of 1536 on iPad4 and 10% of 640 on iPhone5). The result would be that I would get the clipping of the background image that I want, but the other widgets would position themselves so they don't get clipped.

 Is there a way to do this or do I have to write my own script?



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Anchoring to Screen Dimensions
« Reply #1 on: October 26, 2014, 09:35:35 PM »
Just anchor it to the left/right as well as top/bottom. If it's anchored to the left side, it will stay on the left side. Check the first example that comes with NGUI.

DevMan5000

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Anchoring to Screen Dimensions
« Reply #2 on: October 29, 2014, 10:00:59 PM »
thanks for responding.

In this case, I actually don't want it to anchor to the left/right, just top.

That example was very helpful, I should have thought to review that again.

The anchor system has a really steep learning curve, IMHO. It seems straightforward until you start using it and considering how it will react on each of the platforms. IDK, maybe my thought process is just coming from a totally different place.