浏览代码

Fix GDScript enum docs for 3.1

Rémi Verschelde 6 年之前
父节点
当前提交
a30183a4c4
共有 1 个文件被更改,包括 7 次插入5 次删除
  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