Hi all, I’m making a map game set in the cold war and am wondering how to create labels for countries similar to the ones in HOI4:

My question is, how do I:

a) Find the largest possible text size/width of text that fits in a territory’s area2D, taking into account the length of the name (e.g. “Canada” vs “German Democratic Republic”)

b) Create a label that spans this width with the correct position, angle, margins/padding, etc.

c) Change the size of the label dynamically when countries gain or lose territory

Also note that, since some countries have empires (see UK, France…) or faraway territories (see U.S. with Alaska), and some are island nations (see Indonesia) there can also be multiple collision shapes rather than only one. Maybe a label could be created for each collision shape as long as it’s not a tenny tiny island?

Also, a bit off-topic, but I got a pause screen working! Hooray!

  • Ember James@lemmy.ca
    link
    fedilink
    arrow-up
    2
    ·
    29 days ago

    Create a new scene for the country. Arrange the nodes so the area2d is the main node, and the label is a child of that node. Make sure that the label inherits traits from its parent node.

    When you resize or move the Area2d it should now resize the label along with it.

    • sbird@sopuli.xyzOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      28 days ago

      Unfortunately this wouldn’t work as there’s a lot more than one country. I would have to make a label for every country, in which case I might as well just resize the labels myself…