|
@@ -44,7 +44,11 @@ Here is a complete class example based on these guidelines:
|
|
|
|
|
|
func _init():
|
|
func _init():
|
|
add_to_group("state_machine")
|
|
add_to_group("state_machine")
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ func _enter_tree():
|
|
|
|
+ print("this happens before the ready method!")
|
|
|
|
+
|
|
|
|
|
|
func _ready():
|
|
func _ready():
|
|
connect("state_changed", self, "_on_state_changed")
|
|
connect("state_changed", self, "_on_state_changed")
|
|
@@ -88,6 +92,13 @@ Here is a complete class example based on these guidelines:
|
|
print("state changed")
|
|
print("state changed")
|
|
state_changed.emit()
|
|
state_changed.emit()
|
|
|
|
|
|
|
|
+
|
|
|
|
+ class State:
|
|
|
|
+ var foo = 0
|
|
|
|
+
|
|
|
|
+ func _init():
|
|
|
|
+ print("Hello!")
|
|
|
|
+
|
|
.. _formatting:
|
|
.. _formatting:
|
|
|
|
|
|
Formatting
|
|
Formatting
|
|
@@ -703,10 +714,12 @@ We suggest to organize GDScript code this way:
|
|
11. onready variables
|
|
11. onready variables
|
|
|
|
|
|
12. optional built-in virtual _init method
|
|
12. optional built-in virtual _init method
|
|
- 13. built-in virtual _ready method
|
|
|
|
- 14. remaining built-in virtual methods
|
|
|
|
- 15. public methods
|
|
|
|
- 16. private methods
|
|
|
|
|
|
+ 13. optional built-in virtual _enter_tree() method
|
|
|
|
+ 14. built-in virtual _ready method
|
|
|
|
+ 15. remaining built-in virtual methods
|
|
|
|
+ 16. public methods
|
|
|
|
+ 17. private methods
|
|
|
|
+ 18. subclasses
|
|
|
|
|
|
We optimized the order to make it easy to read the code from top to bottom, to
|
|
We optimized the order to make it easy to read the code from top to bottom, to
|
|
help developers reading the code for the first time understand how it works, and
|
|
help developers reading the code for the first time understand how it works, and
|