I have an idea on how to make the buttons update more responsively when you can afford to purchase them. It appears to me that they are on a timer, and that's the easy way to do it, but it's not the way that feels the best to the player. Additionally, it'll better on performance!
Do something like this. I am also using ChronoDK's Big class, but I changed the func names. I forget what they were originally called. Also, I am using Godot 3.5. The terminology for signals changed in 4.0.
-
This is the global variables singleton, assuming you have the credits variable stored in something like that:
var credits: Big signal credits_gained signal credits_lost func add_credits(amount) -> void: credits.add(amount) emit("credits_gained") func subtract_credits(amount) -> void: credits.minus(amount) emit("credits_lost")
Now, every time the player earns credits in any way, just call "add_credits". Anytime they spend credits, call "subtract_credits".
Then, on every button, do this:
var cost_to_upgrade: Big var button_is_bright: bool func _ready() -> void: global_variables_script.connect("credits_gained", self, "credits_gained") global_variables_script.connect("credits_lost", self, "credits_lost") update_button_cannot_afford() func credits_gained() -> void: if button_is_bright: # it is already visually reflecting # the fact that the player can buy it return if global_variables_script.credits.greaterThan(cost_to_upgrade): update_button_can_afford() func credits_lost() -> void: if not button_is_bright: # it is already visually reflecting # the fact that the player cannot buy it return if global_variables_script.credits.lessThan(cost_to_upgrade): update_button_cannot_afford() func update_button_can_afford() -> void: # this is where you set the modulate or whatever you did to make the button brighter button_is_bright = true pass func update_button_cannot_afford() -> void: # make the button dimmer or whatever button_is_bright = false pass
So what this does is it will only update the button one time, and it will only check if the credits are greaterThan or lessThan one time, too.
Once it is bright, it will STAY that way until the player spends credits, then "credits_lost" is emitted, and every button will check if the player can still afford to buy the thing.
-
I didn't test any of this, and I obviously don't know how you have your code set up. But it was fun to write anyway.
Fun game!