cawez_puzzlebox/ui/menu_modulate.gd
2024-06-19 20:20:38 -04:00

26 lines
670 B
GDScript

extends Node2D
var opaque = false
var alpha = 5
var holding = false
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
modulate.a = modulate.a * exp(-alpha * delta) + int(opaque) * (1.0 - exp(-alpha * delta))
if !opaque:
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
else:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
if Input.get_action_strength("ui_cancel") > 0.0 && !holding:
opaque = !opaque
holding = true
elif Input.get_action_strength("ui_cancel") <= 0.0 :
holding = false