Implemented credits scene
This commit is contained in:
35
GUI/Credits.gd
Normal file
35
GUI/Credits.gd
Normal file
@@ -0,0 +1,35 @@
|
||||
extends CanvasLayer
|
||||
|
||||
export var credits_path: String = 'res://credits.txt'
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_load_credits()
|
||||
return
|
||||
|
||||
|
||||
func _load_credits() -> void:
|
||||
var credits_file: File = File.new()
|
||||
assert(credits_file.file_exists(credits_path), 'Credits file does not exist')
|
||||
assert(credits_file.open(credits_path, File.READ) == OK, 'Credits file failed to open')
|
||||
|
||||
while not credits_file.eof_reached():
|
||||
var line: String = credits_file.get_line()
|
||||
if line == '':
|
||||
continue
|
||||
|
||||
var label: Label = Label.new()
|
||||
label.set_custom_minimum_size(Vector2(3200, 0))
|
||||
label.set_align(Label.ALIGN_CENTER)
|
||||
label.set_valign(Label.VALIGN_CENTER)
|
||||
label.set_autowrap(true)
|
||||
label.set_text(line)
|
||||
$'Credits/Credits Items'.add_child(label)
|
||||
credits_file.close()
|
||||
return
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed('ui_cancel'):
|
||||
queue_free()
|
||||
return
|
Reference in New Issue
Block a user