|
@@ -801,7 +801,7 @@ We suggest to organize GDScript code this way:
|
|
13. remaining static methods
|
|
13. remaining static methods
|
|
14. overridden built-in virtual methods:
|
|
14. overridden built-in virtual methods:
|
|
1. _init()
|
|
1. _init()
|
|
- 2. _enter_tree()
|
|
|
|
|
|
+ 2. _enter_tree()
|
|
3. _ready()
|
|
3. _ready()
|
|
4. _process()
|
|
4. _process()
|
|
5. _physics_process()
|
|
5. _physics_process()
|
|
@@ -813,7 +813,7 @@ We suggest to organize GDScript code this way:
|
|
And put the class methods and variables in the following order depending on their access modifiers:
|
|
And put the class methods and variables in the following order depending on their access modifiers:
|
|
|
|
|
|
::
|
|
::
|
|
-
|
|
|
|
|
|
+
|
|
1. public
|
|
1. public
|
|
2. private
|
|
2. private
|
|
|
|
|
|
@@ -829,7 +829,6 @@ This code order follows four rules of thumb:
|
|
4. The object's construction and initialization functions, ``_init`` and
|
|
4. The object's construction and initialization functions, ``_init`` and
|
|
``_ready``, come before functions that modify the object at runtime.
|
|
``_ready``, come before functions that modify the object at runtime.
|
|
|
|
|
|
-
|
|
|
|
Class declaration
|
|
Class declaration
|
|
~~~~~~~~~~~~~~~~~
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
@@ -838,7 +837,9 @@ first line of the script.
|
|
|
|
|
|
Follow with the optional ``@icon`` then the ``class_name`` if necessary. You can turn a
|
|
Follow with the optional ``@icon`` then the ``class_name`` if necessary. You can turn a
|
|
GDScript file into a global type in your project using ``class_name``. For more
|
|
GDScript file into a global type in your project using ``class_name``. For more
|
|
-information, see :ref:`doc_gdscript_basics_class_name`.
|
|
|
|
|
|
+information, see :ref:`doc_gdscript_basics_class_name`. If the class is meant
|
|
|
|
+to be an :ref:`abstract class <doc_gdscript_basics_abstract_class>`,
|
|
|
|
+add ``abstract`` *before* the ``class_name`` keyword, but on the same line.
|
|
|
|
|
|
Then, add the ``extends`` keyword if the class extends a built-in type.
|
|
Then, add the ``extends`` keyword if the class extends a built-in type.
|
|
|
|
|
|
@@ -849,7 +850,7 @@ and how other developers should use it, for example.
|
|
|
|
|
|
::
|
|
::
|
|
|
|
|
|
- class_name MyNode
|
|
|
|
|
|
+ abstract class_name MyNode
|
|
extends Node
|
|
extends Node
|
|
## A brief description of the class's role and functionality.
|
|
## A brief description of the class's role and functionality.
|
|
##
|
|
##
|
|
@@ -1066,5 +1067,3 @@ that type will be used to infer the type of the var.
|
|
This option is considered more :ref:`type-safe<doc_gdscript_static_typing_safe_lines>` than type hints,
|
|
This option is considered more :ref:`type-safe<doc_gdscript_static_typing_safe_lines>` than type hints,
|
|
but also less null-safe as it silently casts the variable to ``null`` in case of a type mismatch at runtime,
|
|
but also less null-safe as it silently casts the variable to ``null`` in case of a type mismatch at runtime,
|
|
without an error/warning.
|
|
without an error/warning.
|
|
-
|
|
|
|
-
|
|
|