this post was submitted on 27 Sep 2025
6 points (87.5% liked)

Godot

7267 readers
14 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 2 years ago
MODERATORS
 

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!

you are viewing a single comment's thread
view the rest of the comments
[–] Arkouda@lemmy.ca 2 points 3 months ago (1 children)

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.

[–] sbeak@sopuli.xyz 1 points 3 months ago (1 children)

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…

[–] Arkouda@lemmy.ca 1 points 3 months ago (1 children)

You are only using one Area for the entire map?

[–] sbeak@sopuli.xyz 1 points 3 months ago

No, each country is its own area.