So I’ve started making a grand strategy game for fun kinda like the Paradox ones.
What a grand strategy is is like a game where there’s countries on the map and you play as one and do stuff (sorry for bad explanation.)
My issue is where the countries’ names get displayed.
So far all you can do is select a country and start taking provinces by just clicking on them.
Now, Portugal and Aragon name placement is fine, but Castile is not.
Here is my code and the game all in one image because of the stupid one image requirement for new users:
Now, what the text is wrongly doing is selecting all the provinces that are of it’s country, BUT the name gets placed closest to the “center province” of the game. The center province is where Castile’s name starts and is literally just the middle. The reason I know this is because when I took that one province close to the center province as Portugal, the name flocked there, besides that the actual land to the west was way bigger. Aragon’s and Portugal’s names are fine at the start, but as soon as you take one province closer to the center one they immediately flock there. How can I fix this? This seems like such a simple issue. Also, GDevelop, please add the ability to draw text on the screen with code instead of having to make text objects for every text because goodness labeling every country is going to be tedious.
The rule of one image per post for new users is not stupid at all. I will explain why: because there are a lot of new users asking for help without even showing their events or sharing their projects to be helped (and as a former user of GDevelop and this forum I can tell you it was not always the case), and also because is excruciatingly frustrating trying to blindly help someone who doesn’t understand why something isn’t working. And it can be the simplest thing in the world, which is fine because we all started learning somewhere, but that’s why these and other rules are important to keep the forum consistent, such as the one that says posts should have descriptive titles and not just sentences like “I have a problem”, “Help me”, “I don’t know what to do”.
It is perfectly possible to dynamically write things on the scene during runtime. This is done by creating a single text object and creating instances of it and changing the text of each instance using events. Examples included in each GDevelop distribution include projects that demonstrate how to manipulate the text object dynamically.
Unfortunately, the file the user @UlisesFreitas very kindly shared with you is an old version that cannot be opened with GDevelop 5.
Regarding the positioning problem, it is difficult to know why your project shows this behavior, because we cannot see what other events are affecting the objects and the variables. To begin with, I can see the text labels align to the position of the “Provinces” object and that you are dynamically pushing the “Provinces” object through the scene instead of locating it in coordinates. I have no idea how that work or exactly what you intend to achieve, but it doesn’t seem like an efficient way to locate objects in a simple strategy game. For later help is necessary to take a look at the project.
Si te cuesta explicarte en inglés, podés escribirme en español por mensaje privado y te puedo ayudar con tu problema.
Provinces is a group of objects that comprises of every object individually. Every province is a separate object. There are no other events effecting those. The only other code I have in my project are WASD to move, and then right click to select a country, and left click to take provinces, which have nothing to do with where the text is placed. Thanks, I will do the instance thing to make more texts. However, the positioning problem still isn’t solved.
I’ll try to send the project to you. It will appear here in like 5-10 minutes maybe?
When you use Provinces.X/Y(), GDevelop picks one of the Provinces objects that met the conditions.
If you want the name to go to the biggestblock of provinces, you need to find an algorithm for that and then tell GDevelop to place the text there.
If you have an object for every iberic province then it isn’t necessary to set the correspondent text label by referencing all the Provinces group and then trying to filter them by a variable… just go for the right object. Example: “Change the X position of CastileText to Castile.X()”, and so on.
Instead of moving all your objects around you can use the “Center camera on an object” action to move the camera. You can set a invisible object (opacity = 0) and set the camera to always be centered on it, then just move around that object to hover the camera over the map.
The use of dynamic variables will make the work a lot easier.