![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Gamergo |
Good day mates,
I’m currently working on a little strategy game with planets and every planet has different values like food, population etc.
I have a building system where you can build housing which increases the population or farms to increase food. These values are displayed by labels and the numbers in the labels should change depending on the things you build.
The problem is that if I write it so that a starting value is assigned to each category and displayed in the labels and then the values change, the new value overlaps with the old one which is quite strange. That means that the new numbers are unreadable.
Pictures for reference:
And here is my code (with the starting value displayed):
extends Button
var PlanetPop = 1000
var PlanetFood = 100
var PlanetIndustry = 10
var PlanetTroops = 0
func _ready():
pass
func _process(delta):
$PlanetOverview/Population/PopNumber.text = str(PlanetPop)
func _on_Planet_pressed():
$PlanetOverview.visible = !$PlanetOverview.visible
func _on_BuildHousing_pressed():
buy_Housing_upgrade()
func buy_Housing_upgrade():
var CreditChange = get_node(“/root/InGame”)
if CreditChange.Credits >= 250 :
CreditChange.Credits -= 250
PlanetPop += 100
$PlanetOverview/Population/PopNumber.text = str(PlanetPop)