26 lines
720 B
GDScript3
26 lines
720 B
GDScript3
|
extends CanvasItem
|
||
|
|
||
|
class_name BlackScreen
|
||
|
|
||
|
var animation_counter = 0.0
|
||
|
var animation_duration : float
|
||
|
var animation = null
|
||
|
|
||
|
func animate(_animation, duration : float):
|
||
|
animation_counter = 0.0
|
||
|
animation_duration = duration
|
||
|
animation = _animation
|
||
|
print('animating!' + (animation if animation != null else 'null') + ' - ' + String(animation_duration))
|
||
|
|
||
|
func _process(delta):
|
||
|
if animation != null:
|
||
|
if animation == 'fadein':
|
||
|
modulate.a = lerp(1, 0, clamp(animation_counter / animation_duration, 0, 1))
|
||
|
elif animation == 'fadeout':
|
||
|
modulate.a = lerp(0, 1, clamp(animation_counter / animation_duration, 0, 1))
|
||
|
elif animation == 'black':
|
||
|
modulate.a = 1
|
||
|
else:
|
||
|
modulate.a = 0
|
||
|
animation_counter += delta
|