Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DoGot |
Im trying to make a shop systems, and one of the problems that faced while implementing this is that I cannot find a better alternative to process listen for the click and what ends up happening is that the script buys until all the money is gone.
Also, each case is a unique button(as in a button node, not a button on the keyboard)
using the lastest version of GoDot (3.2)
Code below:
extends Sprite
var Cash = 200
onready var Shop = get_node(“/root/Node2D/Player/Camera2D/Shop”)
func buy():
while Cash:
match int(Shop.case):
0:
Cash -= 100
print(Cash)
1:
Cash -= 50
print(Cash)
2:
Cash -= 5
3:
Cash -= 5
print(Cash)
4:
Cash -= 200
5:
Cash -= 25
6:
Cash -= 15
#Chair
yield(get_tree(), "idle_frame")
func _process(_delta):
if Input.is_action_pressed(“click”):
buy()
else:
pass