Răsfoiți Sursa

Merge pull request #2996 from Calinou/add-gdscript-enums-guideline

Add an enum naming guideline to the GDScript style guide
Nathan Lovato 5 ani în urmă
părinte
comite
c640a90329
1 a modificat fișierele cu 17 adăugiri și 4 ștergeri
  1. 17 4
      getting_started/scripting/gdscript/gdscript_styleguide.rst

+ 17 - 4
getting_started/scripting/gdscript/gdscript_styleguide.rst

@@ -242,11 +242,24 @@ Use past tense:
     signal door_opened
     signal score_changed
 
-Constants
-~~~~~~~~~
+Constants and enums
+~~~~~~~~~~~~~~~~~~~
 
-Use CONSTANT\_CASE, all caps, with an underscore (\_) to separate words:
-``const MAX_SPEED = 200``
+Use CONSTANT\_CASE, all caps, with an underscore (\_) to separate words.
+
+Enum *names* (if any) should use PascalCase, but their *values* should be in
+CONSTANT\_CASE.
+
+::
+
+    const MAX_SPEED = 200
+
+    enum Element {
+        EARTH,
+        WATER,
+        AIR,
+        FIRE,
+    }
 
 Static typing
 -------------