【问题标题】:godot sound won't play in scriptgodot 声音不会在脚本中播放
【发布时间】:2023-01-23 05:17:19
【问题描述】:

所以在我的投币脚本中,我玩它播放一个名为 coin.wav 的文件,但我听不到它播放

代码:

extends Area2D

signal coin_collected

func _on_coin_body_entered(_body):
    emit_signal("coin_collected")
    set_collision_mask_bit(0, false)
    print("collected")
    $coin_sound.play()
    print("stared sound")
    queue_free()

场景:

注意:如果打开自动播放,它会播放声音,所以我知道它不是文件

【问题讨论】:

    标签: godot gdscript


    【解决方案1】:

    好吧,那是因为在曲目播放之前我正在做queue_free()

    【讨论】:

      【解决方案2】:
      We had exactly the same problem, however, we answered this solution by 
      adding a slight time delay just after the line 
      
      Actual Example
      

      ''' func _on_Gift_body_entered(正文): 如果(body.get_name()==“玩家”): GameManager.Score = GameManager.Score +10 $scoresnd.play() 产量(get_tree()。​​create_timer(0.2),“超时”) 队列空闲() '''

      【讨论】:

        猜你喜欢
        • 2012-10-01
        • 1970-01-01
        • 2013-08-03
        • 2011-08-12
        • 1970-01-01
        • 1970-01-01
        • 2015-03-07
        • 2023-04-06
        • 1970-01-01
        相关资源
        最近更新 更多