Author Topic: Nesting Anchors  (Read 3417 times)

kruncher

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Nesting Anchors
« on: October 07, 2013, 09:21:09 PM »
Hey

I am trying to figure out how to anchor a sprite (A) to the bottom of the screen, and then anchor another sprite (B) to the right of sprite (A):
  1. Root
  2.   |-- Panel
  3.         |-- Anchor Bottom
  4.                       |-- Sprite (A) 500 pixels wide
  5.                                 |-- Anchor Right
  6.                                               |-- Sprite (B) 50 pixels wide
  7.  
I have also tried setting the container of "Anchor Right" to "Sprite (A)" which doesn't seem to work.

Here is what I am hoping to achieve:
  1. |---------------------------------------------------------------------|
  2. |                                                                     |
  3. |                                                                     |
  4. |                                                                     |
  5. |                                                                     |
  6. |                              "Panel"                                |
  7. |                                                                     |
  8. |                                                                     |
  9. |                                                                     |
  10. |         [A---------------------500---------[B----50----B]A]         |
  11. |---------------------------------------------------------------------|
  12.  

In my scene sprite (A) will stretch to fill the width of the screen with a horizontal margin of 150px.
Sprite (B) represents 25% the width of sprite (A).

I hope to combine the use of UIAnchor and UIStretch to achieve this.
« Last Edit: October 07, 2013, 09:27:44 PM by kruncher »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Nesting Anchors
« Reply #1 on: October 08, 2013, 01:17:51 AM »
Make them siblings. Unless you have the latest Pro version, UIAnchor needs to be siblings with whatever it's anchoring to, not a child of it.

kruncher

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 78
    • View Profile
Re: Nesting Anchors
« Reply #2 on: October 08, 2013, 02:14:27 AM »
Thanks, worked a charm!

I had been messing around for about an hour trying to figure that out :P