26 lines
670 B
GDScript
26 lines
670 B
GDScript
extends Node2D
|
|
|
|
var opaque = true
|
|
var alpha = 10
|
|
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
|