This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

How do I make a label fixed ?

EMS21EMS21 Posts: 8Member

Hi,I am trying to fix my label in a particular spot . I have scavenged the internet for answers and I am very new to Godot and programming . Any support will help . Thank you in Advance


  • MegalomaniakMegalomaniak Posts: 2,580Admin

    Could you perhaps tell us a little about the structure of your node hierarchy and perhaps give a visual example of how you would like your label to be?

  • TwistedTwiglegTwistedTwigleg Posts: 2,561Admin

    If you make the label a child of a Node2D, then I think it will ignore the anchor positioning and will stay fixed relative to the position of its parent Node2D.

  • EMS21EMS21 Posts: 8Member
    edited May 2020

    Thanks a lot !!!

  • EMS21EMS21 Posts: 8Member

    It doesn't work , perhaps you guys got my question wrong or I didn't frame it properly.
    I want my label to move with the camera 2d .

  • TwistedTwiglegTwistedTwigleg Posts: 2,561Admin

    Oh, in that case, there are two ways you can do this easily, depending on your project and what you are looking for.

    The easiest is to have the label node as a child of the Camera2D node. Then move move/translate it to whatever position you want it to be fixed to. Then it should stay relative to that position.

    The second way is to use a Control node with the anchor set to full rect, and then have the label as a child-node of that Control node. Then you can set the anchor of the child label node to whatever corner/position is closest to where you want the label to stay with a scaled screen.
    To set the anchor easily in the editor, when you select a Control node there should be a dropdown called Layout, if I recall correctly, which allows you to set the anchors.

    Additionally, you'll need to go to the project settings and set the scale mode. I think its project settings -> display/window -> expand mode. There should be two options: 2d and viewport. There should also be settings there to handle different aspect ratios.

    I think either method should give you the same result. I have not had the time to test either, but I think I've used both in various projects and its worked okay.

  • cyberealitycybereality Posts: 928Moderator

    You can also make your Label a child of a CanvasLayer.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.