【问题标题】:how to execute a function inside the process function of godot every 1min?如何每1分钟在godot的进程函数中执行一个函数?
【发布时间】:2021-04-06 23:03:35
【问题描述】:

我需要实施每1分钟从用户那里扣钱。

我会这样做Player.gd

var game_started = false
var time_start = 0
var time_now = 0
func _process(delta):
   if game_started == true:
   //deduct_one_coin_every_one_minute(uid)

func start(pos):
    print("clicked start the game");
    time_start = OS.get_unix_time()
    set_process(true)
    game_started = true

如何调用或执行函数deduct_one_coin_every_one_minute(uid)

【问题讨论】:

    标签: godot gdscript


    【解决方案1】:

    这可能最好使用Timer 节点来解决。您可以在场景编辑器或代码中将其添加到您的场景中,并将timeout 信号连接到您的deduct_one_coin_every_one_minute() 函数。然后,将wait_time 设置为60 并调用start()

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-19
      • 2013-02-03
      • 2014-05-25
      • 2012-04-29
      • 2018-01-17
      • 2013-03-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多