Skip to content

Commit

Permalink
PauseButton and auto-pause setting fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MylesScholz committed May 22, 2024
1 parent 0b1e637 commit e91a6b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 4 additions & 11 deletions MenuPauseCheck.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,17 @@ extends CheckButton

var pause_button = null
var menu_panel = null
var toggled_check = false
var current_state = false
var enabled = false

# Called when the node enters the scene tree for the first time.
func _ready():
pause_button = get_parent().get_parent().get_parent().get_parent().get_node("NavBar/SpeedControlPanel/PauseButton")
menu_panel = get_parent().get_parent().get_parent()


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var new_state = toggled_check and menu_panel.visible
if new_state != current_state:
current_state = new_state
if current_state:
pause_button.pause()
else:
pause_button.unpause()
if enabled and menu_panel.visible:
pause_button.pause()

func _toggled(toggled_on):
toggled_check = toggled_on
enabled = toggled_on
2 changes: 2 additions & 0 deletions PauseButton.gd
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ func pause_functionality():

func unpause(): # If paused, unpause
if (Engine.time_scale == 0):
pressed_check = false
texture_normal = normal_texture
pause_functionality()

func pause(): # If unpaused, pause
if (Engine.time_scale != 0):
pressed_check = true
texture_normal = pressed_texture
pause_functionality()

Expand Down

0 comments on commit e91a6b1

Please sign in to comment.