Author Topic: HUD Text Attached to the GUI and anchoring of objects that sometimes move  (Read 1496 times)

Darkness

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 90
    • View Profile
1st issue:
So I'm working on having money pop up on the screen when it is dropped by mobs and I'd like to attach a HUD Text object to the actual GUI of the game.  So that when cash is dropped it is sent to the HUD Text object and then added to a label below it.  The problem I have is how to do this?  The object would need to be anchored to a certain side of the screen so that when the resolution changes it doesn't get messed up.  On top of that, it needs to be visible at a specific location on the screen.

My GUI is a 2D since it's your standard RPG GUI with action bars and the like.  Nothing special there.  Any ideas on how to do this?

2nd issue:
Also, I have been fighting how to anchor things that move to the edge of the screen without much success.  The anchoring gets wonky when I run the move script, so I'm curious what needs to be done to lock certain moveable elements to the edge of the screen for when resolution changes and unlock them when I need to move them off (cut-scenes, talking to NPCs, etc.)?  For objects that don't move, I can anchor them fine.

Thanks in advance.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
HUDText is just a script -- it's meant to go on a game object in the UI hierarchy to begin with. If you want it anchored, either use UIAnchor, or make it a child of a widget that's anchored. You can use an invisible widget -- ALT+SHIFT+W.

You can't anchor movable objects. You can't have position changes coming from different sources, it's a conflict. Instead, anchor a widget, and move its child. For example:

UIWidget (anchored)
- UISprite (movable)