We use a root node of Node2D and attach a Panel and Label. Both the Panel and Label take the entire window of 200 by 200.
An enum can be used for defining consecutive integers. They are often used in state management. It makes more sense to check if state == RUNNING rather than state == 0.
This script illustrates use of enum, both unnamed and named versions. The unnamed is same as defining many const statements with consecutive integer values, while the named results in dictionary. The dictionary value can be read as STATE.ST1 or STATE['ST1']
extends Node2D
enum {STATE1, STATE2, STATE3}
enum STATE {ST1, ST2, ST3}
var string
func _ready():
$Label.set_align(Label.ALIGN_CENTER)
$Label.set_valign(Label.VALIGN_CENTER)
string = 'STATE1 = ' + str(STATE1) + '\n'
string += 'STATE2 = ' + str(STATE2) + '\n'
string += 'STATE3 = ' + str(STATE3) + '\n'
string += 'STATE.ST1 = ' + str(STATE.ST1) + '\n'
string += 'STATE.ST2 = ' + str(STATE.ST2) + '\n'
string += 'STATE.ST3 = ' + str(STATE.ST3)
$Label.set_text(string)
This is the output:
Thank you!
ReplyDelete