Skip to content

Commit

Permalink
fix: don't trigger sfx two times on yellow grid
Browse files Browse the repository at this point in the history
  • Loading branch information
florianvazelle committed Jan 1, 2024
1 parent 0598929 commit 0cb4da2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scripts/item/grid.gd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func toggle(receptacle_state: bool):
_activated_num_fuse += 1
else:
_activated_num_fuse -= 1


var old_state := _state
_state = _is_active()

tween = get_tree().create_tween()
Expand All @@ -49,9 +50,11 @@ func toggle(receptacle_state: bool):
tween.tween_property(self, "global_position", initial, 1)
tween.set_trans(tween.TRANS_SINE)

sfx.play()
tween.play()

if old_state != _state:
sfx.play()


func _is_active() -> bool:
return _activated_num_fuse == required_num_fuse

0 comments on commit 0cb4da2

Please sign in to comment.