improve pause menu behavior

This commit is contained in:
Arnaud Vergnet 2021-04-09 11:25:11 +02:00
parent ef5e8268c5
commit df6a44bc8e
3 changed files with 12 additions and 4 deletions

View file

@ -2,18 +2,23 @@ extends Node2D
onready var texture : TextureRect = $TextureRect
var force_stop = false
var moving = false
func stop():
moving = false
force_stop = true
texture.material.set_shader_param("scroll_speed", 0)
func start():
moving = true
force_stop = false
texture.material.set_shader_param("scroll_speed", 0.2)
func _process(delta):
if get_tree().paused and moving:
stop()
elif not get_tree().paused and not moving:
start()
if not force_stop:
if get_tree().paused and moving:
stop()
force_stop = false
elif not get_tree().paused and not moving:
start()

View file

@ -11,6 +11,7 @@ font_data = ExtResource( 4 )
[node name="PauseMenu" type="Control"]
pause_mode = 2
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )

View file

@ -51,6 +51,8 @@ __meta__ = {
margin_left = 1836.0
margin_right = 1900.0
margin_bottom = 64.0
focus_mode = 0
enabled_focus_mode = 0
texture_normal = ExtResource( 1 )
[node name="ColorRect" type="ColorRect" parent="MarginContainer/HBoxContainer/TextureButton"]