diff --git a/community/contributing/updating_the_class_reference.rst b/community/contributing/updating_the_class_reference.rst index 0e3250a24..4575d669a 100644 --- a/community/contributing/updating_the_class_reference.rst +++ b/community/contributing/updating_the_class_reference.rst @@ -288,7 +288,7 @@ the end of the description: [b]Note:[/b] Only available when using the GLES2 renderer. To denote crucial information that could cause security issues or loss of data -if not followed carefully, add a paragraph starting with "[b]Warning:[/b] at the +if not followed carefully, add a paragraph starting with "[b]Warning:[/b]" at the end of the description: .. code-block:: none diff --git a/getting_started/scripting/gdscript/gdscript_styleguide.rst b/getting_started/scripting/gdscript/gdscript_styleguide.rst index f0aa5d798..a65fa85e7 100644 --- a/getting_started/scripting/gdscript/gdscript_styleguide.rst +++ b/getting_started/scripting/gdscript/gdscript_styleguide.rst @@ -735,11 +735,33 @@ Static typing Since Godot 3.1, GDScript supports :ref:`optional static typing`. -Type hints -~~~~~~~~~~ +Declared types +~~~~~~~~~~~~~~ -Place the colon right after the variable's name, without a space, and let the -GDScript compiler infer the variable's type when possible. +To declare a variable's type, use ``: ``: + +:: + + var health: int = 0 + +To declare the return type of a function, use ``-> ``: + +:: + + func heal(amount: int) -> void: + +Inferred types +~~~~~~~~~~~~~~ + +In most cases you can let the compiler infer the type, using ``:=``: + +:: + var health := 0 # The compiler will use the int type. + +However, in a few cases when context is missing, the compiler falls back to +the function's return type. For example, ``get_node()`` cannot infer a type +unless the scene or file of the node is loaded in memory. In this case, you +should set the type explicitly. **Good**: @@ -747,8 +769,6 @@ GDScript compiler infer the variable's type when possible. onready var health_bar: ProgressBar = get_node("UI/LifeBar") - var health := 0 # The compiler will use the int type. - **Bad**: :: @@ -756,15 +776,3 @@ GDScript compiler infer the variable's type when possible. # The compiler can't infer the exact type and will use Node # instead of ProgressBar. onready var health_bar := get_node("UI/LifeBar") - -When you let the compiler infer the type hint, write the colon and equal signs together: ``:=``. - -:: - - var health := 0 # The compiler will use the int type. - -Add a space on either sides of the return type arrow when defining functions. - -:: - - func heal(amount: int) -> void: diff --git a/tutorials/2d/img/autotile_template_2x2.png b/tutorials/2d/img/autotile_template_2x2.png new file mode 100644 index 000000000..17b4bc7b4 Binary files /dev/null and b/tutorials/2d/img/autotile_template_2x2.png differ diff --git a/tutorials/2d/img/autotile_template_3x3_minimal.png b/tutorials/2d/img/autotile_template_3x3_minimal.png new file mode 100644 index 000000000..cadfb7bf0 Binary files /dev/null and b/tutorials/2d/img/autotile_template_3x3_minimal.png differ diff --git a/tutorials/2d/img/autotile_template_3x3_minimal_topdown_floor.png b/tutorials/2d/img/autotile_template_3x3_minimal_topdown_floor.png new file mode 100644 index 000000000..1ac9c5d31 Binary files /dev/null and b/tutorials/2d/img/autotile_template_3x3_minimal_topdown_floor.png differ diff --git a/tutorials/2d/img/autotile_template_3x3_minimal_topdown_walls.png b/tutorials/2d/img/autotile_template_3x3_minimal_topdown_walls.png new file mode 100644 index 000000000..beecb2795 Binary files /dev/null and b/tutorials/2d/img/autotile_template_3x3_minimal_topdown_walls.png differ diff --git a/tutorials/2d/img/autotile_template_3x3_minimal_topdown_walls_tall.png b/tutorials/2d/img/autotile_template_3x3_minimal_topdown_walls_tall.png new file mode 100644 index 000000000..314890459 Binary files /dev/null and b/tutorials/2d/img/autotile_template_3x3_minimal_topdown_walls_tall.png differ diff --git a/tutorials/2d/img/autotile_template_3x3_minimal_topdown_walls_thick.png b/tutorials/2d/img/autotile_template_3x3_minimal_topdown_walls_thick.png new file mode 100644 index 000000000..b31be907a Binary files /dev/null and b/tutorials/2d/img/autotile_template_3x3_minimal_topdown_walls_thick.png differ diff --git a/tutorials/2d/using_tilemaps.rst b/tutorials/2d/using_tilemaps.rst index 0cc5a2539..e156b7d39 100644 --- a/tutorials/2d/using_tilemaps.rst +++ b/tutorials/2d/using_tilemaps.rst @@ -211,25 +211,80 @@ can test for. 2x2 mode can only match cells that are part of a 2-by-2 block - cells with no neighbors and lines only one cell wide are not supported. +**Template - Generic:** + +This template can be used for sideways or fully top-down perspectives. +It's designed for a TileMap cell size of 64x64. + +Key: + +- Red: "on" +- White: "off" + +.. image:: img/autotile_template_2x2.png + 3x3 (minimal) ~~~~~~~~~~~~~ In 3x3 (minimal) mode, each bitmask contains 9 bits (4 corners, 4 edges, -1 center). - -The 4 corner bits work the same as in 2x2 mode. +1 center). The 4 corner bits work the same as in 2x2 mode. When an edge bit is "on", the cell which shares that edge must be filled. When an edge bit is "off", the cell which shares that edge must be empty. -The center bit should be "on" for any tile you wish to use. - -Note that in this mode, it makes no sense for a corner bit to be "on" when -either edge bit adjacent to it is not "on". +The center bit should be "on" for any tile you wish to use. Note that in this +mode, it makes no sense for a corner bit to be "on" when either edge bit +adjacent to it is not "on". A total of 47 tiles would be needed to provide exactly one bitmask for each arrangement that this mode can test for. +.. note:: + + Right-click an image and choose **Save image as…** to save it. + +**Template - Generic:** + +This template can be used for sideways or fully top-down perspectives. +All templates below are designed for a TileMap cell size of 64x64, but you may +have to use different subtile sizes for top-down templates as described below. + +Key: + +- Red: "on" +- White: "off" + +.. image:: img/autotile_template_3x3_minimal.png + + +**Template - Top-down floor in 3/4 perspective:** + +Key (applies to the four templates below): + +- Green: floor +- Cyan: wall +- Yellow: top of wall +- Transparent: air + +.. image:: img/autotile_template_3x3_minimal_topdown_floor.png + +**Template - Top-down wall in 3/4 perspective:** + +.. image:: img/autotile_template_3x3_minimal_topdown_walls.png + +**Template - Top-down wall in 3/4 perspective (thick walls):** + +When using this template, set the TileSet subtile size to ``Vector2(64, 88)``. + +.. image:: img/autotile_template_3x3_minimal_topdown_walls_thick.png + +**Template - Top-down wall in 3/4 perspective (tall walls):** + +When using this template, set the "Snap Options" Step to ``Vector2(64, 184)`` +and the "Selected Tile" Texture offset to height minus the cell size. +This means the texture offset should be ``Vector2(0, -120)``: + +.. image:: img/autotile_template_3x3_minimal_topdown_walls_tall.png 3x3 ~~~ diff --git a/tutorials/gui/bbcode_in_richtextlabel.rst b/tutorials/gui/bbcode_in_richtextlabel.rst index 7cff10a55..06ab30cfd 100644 --- a/tutorials/gui/bbcode_in_richtextlabel.rst +++ b/tutorials/gui/bbcode_in_richtextlabel.rst @@ -41,51 +41,53 @@ markup. All changes to the text must be done in the BBCode parameter. .. note:: - For BBCode tags such as ``[b]`` (bold) or ``[i]`` (italics) to work you must - set up custom fonts for the RichTextLabel node first. + For BBCode tags such as ``[b]`` (bold), ``[i]`` (italics) or ``[code]`` to + work, you must set up custom fonts for the RichTextLabel node first. + + There are no BBCode tags to control vertical centering of text yet. Reference --------- -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| Command | Tag | Description | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **bold** | ``[b]{text}[/b]`` | Makes {text} bold. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **italics** | ``[i]{text}[/i]`` | Makes {text} italics. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **underline** | ``[u]{text}[/u]`` | Makes {text} underline. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **strikethrough** | ``[s]{text}[/s]`` | Makes {text} strikethrough. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **code** | ``[code]{text}[/code]`` | Makes {text} monospace. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **center** | ``[center]{text}[/center]`` | Makes {text} centered. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **right** | ``[right]{text}[/right]`` | Makes {text} right-aligned. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **fill** | ``[fill]{text}[/fill]`` | Makes {text} fill width. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **indent** | ``[indent]{text}[/indent]`` | Increase indent level of {text}. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **url** | ``[url]{url}[/url]`` | Show {url} as such. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **url (ref)** | ``[url=]{text}[/url]`` | Makes {text} reference . | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **image** | ``[img]{path}[/img]`` | Insert image at resource {path}. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **resized image** | ``[img=]{path}[/img]`` | Insert image at resource {path} using (keeps ratio). | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **resized image** | ``[img=x]{path}[/img]`` | Insert image at resource {path} using & . | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **font** | ``[font=]{text}[/font]`` | Use custom font at for {text}. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **color** | ``[color=]{text}[/color]`` | Change {text} color; use name or # format, such as #ff00ff. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **table** | ``[table=]{cells}[/table]`` | Creates a table with of columns. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ -| **cell** | ``[cell]{text}[/cell]`` | Adds cells with the {text} to the table. | -+-------------------+--------------------------------------------+--------------------------------------------------------------+ ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| Command | Tag | Description | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **bold** | ``[b]{text}[/b]`` | Makes {text} bold. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **italics** | ``[i]{text}[/i]`` | Makes {text} italics. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **underline** | ``[u]{text}[/u]`` | Makes {text} underline. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **strikethrough** | ``[s]{text}[/s]`` | Makes {text} strikethrough. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **code** | ``[code]{text}[/code]`` | Makes {text} use the code font (which is typically monospace). | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **center** | ``[center]{text}[/center]`` | Makes {text} horizontally centered. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **right** | ``[right]{text}[/right]`` | Makes {text} horizontally right-aligned. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **fill** | ``[fill]{text}[/fill]`` | Makes {text} fill the RichTextLabel's width. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **indent** | ``[indent]{text}[/indent]`` | Increase the indentation level of {text}. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **url** | ``[url]{url}[/url]`` | Show {url} as such, underline it and make it clickable. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **url (ref)** | ``[url=]{text}[/url]`` | Makes {text} reference (underlined and clickable). | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **image** | ``[img]{path}[/img]`` | Insert image at resource {path}. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **resized image** | ``[img=]{path}[/img]`` | Insert image at resource {path} using (keeps ratio). | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **resized image** | ``[img=x]{path}[/img]`` | Insert image at resource {path} using ×. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **font** | ``[font=]{text}[/font]`` | Use custom font at for {text}. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **color** | ``[color=]{text}[/color]`` | Change {text} color; use name or # format, such as ``#ff00ff``. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **table** | ``[table=]{cells}[/table]`` | Creates a table with of columns. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ +| **cell** | ``[cell]{text}[/cell]`` | Adds cells with the {text} to the table. | ++-------------------+--------------------------------------------+-----------------------------------------------------------------+ Built-in color names ~~~~~~~~~~~~~~~~~~~~ diff --git a/tutorials/io/encrypting_save_games.rst b/tutorials/io/encrypting_save_games.rst index 94060c5ac..dbd3075e2 100644 --- a/tutorials/io/encrypting_save_games.rst +++ b/tutorials/io/encrypting_save_games.rst @@ -26,7 +26,7 @@ But what if someone were to find a way to edit the saved games and assign the items and currency without effort? That would be terrible, because it would help players consume the content much faster, and therefore run out of it sooner than expected. If that happens, they will have -nothing that avoids them to think, and the tremendous agony of realizing +nothing that prevents them from thinking, and the tremendous agony of realizing their own irrelevance would again take over their life. No, we definitely do not want that to happen, so let's see how to diff --git a/tutorials/math/matrices_and_transforms.rst b/tutorials/math/matrices_and_transforms.rst index b2952030b..1adec854d 100644 --- a/tutorials/math/matrices_and_transforms.rst +++ b/tutorials/math/matrices_and_transforms.rst @@ -235,7 +235,7 @@ Putting it all together ~~~~~~~~~~~~~~~~~~~~~~~ We're going to apply everything we mentioned so far onto one transform. -To follow along, create a simple project with a Sprite node and use the +To follow along, create a simple project with a Sprite node and use the Godot logo for the texture resource. Let's set the translation to (350, 150), rotate by -0.5 rad, and scale by 3. @@ -290,7 +290,7 @@ matrix has four total numbers in two :ref:`class_Vector2` values, while a rotation value and a Vector2 for scale only has 3 numbers. The high-level concept for the missing degree of freedom is called *shearing*. -Normally you will always have the basis vectors perpendicular to each +Normally, you will always have the basis vectors perpendicular to each other. However, shearing can be useful in some situations, and understanding shearing helps you understand how transforms work. diff --git a/tutorials/physics/using_kinematic_body_2d.rst b/tutorials/physics/using_kinematic_body_2d.rst index bbbdfe9f7..1398a3d72 100644 --- a/tutorials/physics/using_kinematic_body_2d.rst +++ b/tutorials/physics/using_kinematic_body_2d.rst @@ -265,7 +265,7 @@ Attach a script to the KinematicBody2D and add the following code: public override void _PhysicsProcess(float delta) { GetInput(); - MoveAndCollide(velocity * delta); + MoveAndCollide(_velocity * delta); } }