Browse Source

Fix GDScript enum docs for 3.1

Rémi Verschelde 6 năm trước cách đây
mục cha
commit
a30183a4c4
1 tập tin đã thay đổi với 7 bổ sung5 xóa
  1. 7 5
      getting_started/scripting/gdscript/gdscript_basics.rst

+ 7 - 5
getting_started/scripting/gdscript/gdscript_basics.rst

@@ -658,8 +658,12 @@ Enums
 Enums are basically a shorthand for constants, and are pretty useful if you
 want to assign consecutive integers to some constant.
 
-If you pass a name to the enum, it would also put all the values inside a
-constant dictionary of that name.
+If you pass a name to the enum, it will put all the keys inside a constant
+dictionary of that name.
+
+.. important: The keys in a named enum are not registered as global constants
+              in Godot 3.1 and later, they should be accessed prefixed by the
+              enum's name (``Name.KEY``). See example below.
 
 ::
 
@@ -672,10 +676,8 @@ constant dictionary of that name.
 
     enum State {STATE_IDLE, STATE_JUMP = 5, STATE_SHOOT}
     # Is the same as:
-    const STATE_IDLE = 0
-    const STATE_JUMP = 5
-    const STATE_SHOOT = 6
     const State = {STATE_IDLE = 0, STATE_JUMP = 5, STATE_SHOOT = 6}
+    # Access values with State.STATE_IDLE, etc.
 
 
 Functions