mirror of
https://github.com/Relintai/pandemonium_engine_docs.git
synced 2025-01-21 15:07:22 +01:00
More rst syntax cleanups.
This commit is contained in:
parent
ad9a190287
commit
a688b05603
@ -578,11 +578,11 @@ The editor UI can easily be extended in many ways using add-ons.
|
||||
|
||||
- Generate a theme based on the current editor theme settings.
|
||||
|
||||
- Procedural vector-based theming using `class_StyleBoxFlat`.
|
||||
- Procedural vector-based theming using `StyleBoxFlat`.
|
||||
|
||||
- Supports rounded/beveled corners, drop shadows, per-border widths and antialiasing.
|
||||
|
||||
- Texture-based theming using `class_StyleBoxTexture`.
|
||||
- Texture-based theming using `StyleBoxTexture`.
|
||||
|
||||
Godot's small distribution size can make it a suitable alternative to frameworks
|
||||
like Electron or Qt.
|
||||
@ -605,16 +605,16 @@ File formats
|
||||
- Text-based formats are human-readable and more friendly to version control.
|
||||
- Binary formats are faster to save/load for large scenes/resources.
|
||||
|
||||
- Read and write text or binary files using `class_File`.
|
||||
- Read and write text or binary files using `File`.
|
||||
|
||||
- Can optionally be compressed or encrypted.
|
||||
|
||||
- Read and write `class_JSON` files.
|
||||
- Read and write INI-style configuration files using `class_ConfigFile`.
|
||||
- Read and write `JSON` files.
|
||||
- Read and write INI-style configuration files using `ConfigFile`.
|
||||
|
||||
- Can (de)serialize any Godot datatype, including Vector2/3, Color, ...
|
||||
|
||||
- Read XML files using `class_XMLParser`.
|
||||
- Read XML files using `XMLParser`.
|
||||
- Pack game data into a PCK file (custom format optimized for fast seeking),
|
||||
into a ZIP archive, or directly into the executable for single-file distribution.
|
||||
- `Export additional PCK files<doc_exporting_pcks>` that can be read
|
||||
|
@ -125,7 +125,7 @@ the text. Here's the list of available tags:
|
||||
+----------------------------+--------------------------------------+-----------------------------------+---------------------------------------------------+
|
||||
| Tag | Effect | Usage | Result |
|
||||
+============================+======================================+===================================+===================================================+
|
||||
| [Class] | Link a class | Move the [Sprite]. | Move the `class_Sprite`. |
|
||||
| [Class] | Link a class | Move the [Sprite]. | Move the `Sprite`. |
|
||||
+----------------------------+--------------------------------------+-----------------------------------+---------------------------------------------------+
|
||||
| [method methodname] | Link to a method in this class | Call [method hide]. | Call `hide`. |
|
||||
+----------------------------+--------------------------------------+-----------------------------------+---------------------------------------------------+
|
||||
|
@ -179,7 +179,7 @@ translating.
|
||||
string corresponding to the brief description of a given class to find the
|
||||
first string to translate and all other descriptions from that class should be
|
||||
in the subsequent strings on Weblate. For example, the descriptions for the
|
||||
`class_Node2D` class would have the source string location
|
||||
`Node2D` class would have the source string location
|
||||
``doc/classes/Node2D.xml``.
|
||||
|
||||
A handy tool to locate specific pages/classes is to use Weblate's advanced
|
||||
|
@ -34,7 +34,7 @@ described below.
|
||||
Format a string
|
||||
---------------
|
||||
|
||||
The ``vformat()`` function returns a formatted `class_String`. It behaves
|
||||
The ``vformat()`` function returns a formatted `String`. It behaves
|
||||
in a way similar to C's ``sprintf()``:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
@ -557,10 +557,10 @@ Remember to:
|
||||
But this is not all, depending what you do, you will be greeted with
|
||||
some (hopefully positive) surprises.
|
||||
|
||||
- If you inherit from `class_Node` (or any derived node type, such as
|
||||
- If you inherit from `Node` (or any derived node type, such as
|
||||
Sprite), your new class will appear in the editor, in the inheritance
|
||||
tree in the "Add Node" dialog.
|
||||
- If you inherit from `class_Resource`, it will appear in the resource
|
||||
- If you inherit from `Resource`, it will appear in the resource
|
||||
list, and all the exposed properties can be serialized when
|
||||
saved/loaded.
|
||||
- By this same logic, you can extend the Editor and almost any area of
|
||||
|
@ -26,4 +26,4 @@ Spatial
|
||||
|
||||
.. image:: img/Spatial.png
|
||||
|
||||
Source files: :download:`class_tree.zip <files/class_tree.zip>`.
|
||||
Source files: :download:`tree.zip <files/class_tree.zip>`.
|
||||
|
@ -52,7 +52,7 @@ contain few items make it difficult to navigate the inspector, while missing the
|
||||
benefits of using sections such as folding.
|
||||
|
||||
There are some valid exceptions for this, such as material features in
|
||||
`class_SpatialMaterial`.
|
||||
`SpatialMaterial`.
|
||||
|
||||
This advice also applies to the Project Settings and Editor Settings.
|
||||
|
||||
|
@ -20,13 +20,13 @@ parameters and then adding randomness to them.
|
||||
Particle nodes
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Godot provides two different nodes for 2D particles, `class_Particles2D` and
|
||||
`class_CPUParticles2D`.
|
||||
Godot provides two different nodes for 2D particles, `Particles2D` and
|
||||
`CPUParticles2D`.
|
||||
Particles2D is more advanced and uses the GPU to process particle effects, but that limits
|
||||
it to higher end graphics API, and in our case to the GLES3 renderer. For projects using
|
||||
the GLES2 backend, CPUParticles2D is a CPU-driven option with near feature parity with
|
||||
Particles2D, but lesser performance. While Particles2D is configured via a
|
||||
`class_ParticlesMaterial` (and optionally with a custom shader), the matching options
|
||||
`ParticlesMaterial` (and optionally with a custom shader), the matching options
|
||||
are provided via node properties in CPUParticles2D (with the exception of the trail settings).
|
||||
You can convert a Particles2D node into a CPUParticles2D node by clicking on the node in the
|
||||
inspector, and selecting "Convert to CPUParticles2D" in the "Particles" menu of the toolbar.
|
||||
|
@ -9,7 +9,7 @@ Introduction
|
||||
`Gridmaps` are a tool for creating 3D
|
||||
game levels, similar to the way `TileMap <doc_using_tilemaps>`
|
||||
works in 2D. You start with a predefined collection of 3D meshes (a
|
||||
`class_MeshLibrary`) that can be placed on a grid,
|
||||
`MeshLibrary`) that can be placed on a grid,
|
||||
as if you were building a level with an unlimited amount of Lego blocks.
|
||||
|
||||
Collisions and navigation can also be added to the meshes, just like you
|
||||
@ -27,14 +27,14 @@ button.
|
||||
Creating a MeshLibrary
|
||||
----------------------
|
||||
|
||||
To begin, you need a `class_MeshLibrary`, which is a collection
|
||||
To begin, you need a `MeshLibrary`, which is a collection
|
||||
of individual meshes that can be used in the gridmap. Open the "MeshLibrary_Source.tscn"
|
||||
scene to see an example of how to set up the mesh library.
|
||||
|
||||
.. image:: img/gridmap_meshlibrary1.png
|
||||
|
||||
As you can see, this scene has a `class_Spatial` node as its root, and
|
||||
a number of `class_MeshInstance` node children.
|
||||
As you can see, this scene has a `Spatial` node as its root, and
|
||||
a number of `MeshInstance` node children.
|
||||
|
||||
If you don't need any physics in your scene, then you're done. However, in most
|
||||
cases you'll want to assign collision bodies to the meshes.
|
||||
@ -42,8 +42,8 @@ cases you'll want to assign collision bodies to the meshes.
|
||||
Collisions
|
||||
----------
|
||||
|
||||
You can manually assign a `class_StaticBody` and
|
||||
`class_CollisionShape` to each mesh. Alternatively, you can use the "Mesh" menu
|
||||
You can manually assign a `StaticBody` and
|
||||
`CollisionShape` to each mesh. Alternatively, you can use the "Mesh" menu
|
||||
to automatically create the collision body based on the mesh data.
|
||||
|
||||
.. image:: img/gridmap_create_body.png
|
||||
@ -65,11 +65,11 @@ library. Materials set on the node will be ignored.
|
||||
NavigationMeshes
|
||||
----------------
|
||||
|
||||
Like all mesh instances, MeshLibrary items can be assigned a `class_NavigationMesh`
|
||||
Like all mesh instances, MeshLibrary items can be assigned a `NavigationMesh`
|
||||
resource, which can be created manually, or baked as described below.
|
||||
|
||||
To create the NavigationMesh from a MeshLibrary scene export, place a
|
||||
`class_NavigationMeshInstance` child node below the main MeshInstance for the GridMap
|
||||
`NavigationMeshInstance` child node below the main MeshInstance for the GridMap
|
||||
item. Add a valid NavigationMesh resource to the NavigationMeshInstance and some source
|
||||
geometry nodes below and bake the NavigationMesh.
|
||||
|
||||
@ -133,4 +133,4 @@ the drawing plane higher or lower on its axis.
|
||||
Using GridMap in code
|
||||
---------------------
|
||||
|
||||
See `class_GridMap` for details on the node's methods and member variables.
|
||||
See `GridMap` for details on the node's methods and member variables.
|
||||
|
@ -79,18 +79,18 @@ There are a few reasons this may happen:
|
||||
Say no to Euler angles
|
||||
======================
|
||||
|
||||
The result of all this is that you should **not use** the ``rotation`` property of `class_Spatial` nodes in Godot for games. It's there to be used mainly in the editor, for coherence with the 2D engine, and for simple rotations (generally just one axis, or even two in limited cases). As much as you may be tempted, don't use it.
|
||||
The result of all this is that you should **not use** the ``rotation`` property of `Spatial` nodes in Godot for games. It's there to be used mainly in the editor, for coherence with the 2D engine, and for simple rotations (generally just one axis, or even two in limited cases). As much as you may be tempted, don't use it.
|
||||
|
||||
Instead, there is a better way to solve your rotation problems.
|
||||
|
||||
Introducing transforms
|
||||
----------------------
|
||||
|
||||
Godot uses the `class_Transform` datatype for orientations. Each `class_Spatial` node contains a ``transform`` property which is relative to the parent's transform, if the parent is a Spatial-derived type.
|
||||
Godot uses the `Transform` datatype for orientations. Each `Spatial` node contains a ``transform`` property which is relative to the parent's transform, if the parent is a Spatial-derived type.
|
||||
|
||||
It is also possible to access the world coordinate transform via the ``global_transform`` property.
|
||||
|
||||
A transform has a `class_Basis` (transform.basis sub-property), which consists of three `class_Vector3` vectors. These are accessed via the ``transform.basis`` property and can be accessed directly by ``transform.basis.x``, ``transform.basis.y``, and ``transform.basis.z``. Each vector points in the direction its axis has been rotated, so they effectively describe the node's total rotation. The scale (as long as it's uniform) can also be inferred from the length of the axes. A *basis* can also be interpreted as a 3x3 matrix and used as ``transform.basis[x][y]``.
|
||||
A transform has a `Basis` (transform.basis sub-property), which consists of three `Vector3` vectors. These are accessed via the ``transform.basis`` property and can be accessed directly by ``transform.basis.x``, ``transform.basis.y``, and ``transform.basis.z``. Each vector points in the direction its axis has been rotated, so they effectively describe the node's total rotation. The scale (as long as it's uniform) can also be inferred from the length of the axes. A *basis* can also be interpreted as a 3x3 matrix and used as ``transform.basis[x][y]``.
|
||||
|
||||
A default basis (unmodified) is akin to:
|
||||
|
||||
@ -285,7 +285,7 @@ gdscript GDScript
|
||||
transform.basis = Basis(c)
|
||||
```
|
||||
|
||||
The `class_Quat` type reference has more information on the datatype (it
|
||||
The `Quat` type reference has more information on the datatype (it
|
||||
can also do transform accumulation, transform points, etc., though this is used
|
||||
less often). If you interpolate or apply operations to quaternions many times,
|
||||
keep in mind they need to be eventually normalized. Otherwise, they will also
|
||||
|
@ -3,7 +3,7 @@
|
||||
Introduction to the animation features
|
||||
======================================
|
||||
|
||||
The `class_AnimationPlayer` node allows you to create anything
|
||||
The `AnimationPlayer` node allows you to create anything
|
||||
from simple to complex animations.
|
||||
|
||||
In this guide you learn to:
|
||||
@ -22,7 +22,7 @@ Create an AnimationPlayer node
|
||||
------------------------------
|
||||
|
||||
To use the animation tools we first have to create an
|
||||
`class_AnimationPlayer` node.
|
||||
`AnimationPlayer` node.
|
||||
|
||||
The AnimationPlayer node type is the data container for your animations.
|
||||
One AnimationPlayer node can hold multiple animations, that can
|
||||
@ -233,7 +233,7 @@ values. This can be:
|
||||
- **Discrete:** Only update the property on keyframes.
|
||||
- **Trigger:** Only update the property on keyframes or triggers.
|
||||
Triggers are a type of keyframe used by the
|
||||
``current_animation`` property of a `class_AnimationPlayer`,
|
||||
``current_animation`` property of a `AnimationPlayer`,
|
||||
and Animation Playback tracks.
|
||||
- **Capture:** If the first keyframe's time is greater than ``0.0``, the
|
||||
current value of the property will be remembered and
|
||||
@ -327,7 +327,7 @@ comfortable with Godot's scripting language
|
||||
know that each node type is a class and has a bunch of callable
|
||||
methods.
|
||||
|
||||
For example, the `class_AudioStreamPlayer` node type has a
|
||||
For example, the `AudioStreamPlayer` node type has a
|
||||
method to play an audio stream.
|
||||
|
||||
Wouldn't it be great to use a method at a specific keyframe in an
|
||||
@ -340,7 +340,7 @@ To demonstrate, we're going to use a call method track to play audio at a
|
||||
specific keyframe. Normally to play audio you should use an audio track,
|
||||
but for the sake of demonstrating methods we're going to do it this way.
|
||||
|
||||
Add a `class_AudioStreamPlayer` to the Scene Tree and setup a
|
||||
Add a `AudioStreamPlayer` to the Scene Tree and setup a
|
||||
stream using an audio file you put in your project.
|
||||
|
||||
Click on "Add track" (|Add track|) on the animation panel's track
|
||||
@ -353,7 +353,7 @@ Select "Add Call Method Track" from the list of possible track types.
|
||||
|
||||
Add Call Method Track
|
||||
|
||||
Select the `class_AudioStreamPlayer` node in the selection
|
||||
Select the `AudioStreamPlayer` node in the selection
|
||||
window. Godot adds the track with the reference to the node.
|
||||
|
||||
.. figure:: img/animation_select_audiostreamplayer.png
|
||||
@ -369,7 +369,7 @@ one.
|
||||
.. image:: img/animation_method_options.png
|
||||
|
||||
When Godot reaches the keyframe, Godot calls the
|
||||
`class_AudioStreamPlayer` node's "play" function and the stream
|
||||
`AudioStreamPlayer` node's "play" function and the stream
|
||||
plays.
|
||||
|
||||
You can change its position by dragging it on the timeline, you can also
|
||||
|
@ -3,7 +3,7 @@
|
||||
Playing videos
|
||||
==============
|
||||
|
||||
Godot supports video playback with the `class_VideoPlayer` node.
|
||||
Godot supports video playback with the `VideoPlayer` node.
|
||||
|
||||
Supported playback formats
|
||||
--------------------------
|
||||
@ -49,7 +49,7 @@ Handling resizing and different aspect ratios
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
By default in Godot 4.0, the VideoPlayer will automatically be resized to match
|
||||
the video's resolution. You can make it follow usual `class_Control` sizing
|
||||
the video's resolution. You can make it follow usual `Control` sizing
|
||||
by enabling **Expand** on the VideoPlayer node.
|
||||
|
||||
To adjust how the VideoPlayer node resizes depending on window size,
|
||||
@ -57,7 +57,7 @@ adjust the anchors using the **Layout** menu at the top of the 2D editor
|
||||
viewport. However, this setup may not be powerful enough to handle all use
|
||||
cases, such as playing fullscreen videos without distorting the video (but with
|
||||
empty space on the edges instead). For more control, you can use an
|
||||
`class_AspectRatioContainer` node, which is designed to handle this kind of
|
||||
`AspectRatioContainer` node, which is designed to handle this kind of
|
||||
use case:
|
||||
|
||||
Add an AspectRatioContainer node. Make sure it is not a child of any other
|
||||
@ -87,14 +87,14 @@ to fit the whole screen while avoiding distortion.
|
||||
Displaying a video on a 3D surface
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Using a VideoPlayer node as a child of a `class_Viewport` node,
|
||||
Using a VideoPlayer node as a child of a `Viewport` node,
|
||||
it's possible to display any 2D node on a 3D surface. For example, this can be
|
||||
used to display animated billboards when frame-by-frame animation would require
|
||||
too much memory.
|
||||
|
||||
This can be done with the following steps:
|
||||
|
||||
1. Create a `class_Viewport` node. Set its size to match your video's size
|
||||
1. Create a `Viewport` node. Set its size to match your video's size
|
||||
in pixels.
|
||||
2. Create a VideoPlayer node *as a child of the Viewport node* and specify
|
||||
a video path in it. Make sure **Expand** is disabled, and enable **Autoplay** if needed.
|
||||
|
@ -442,8 +442,8 @@ will create a triangle mesh collision shape, which is a slow, but accurate
|
||||
option for collision detection. This option is usually what you want for level
|
||||
geometry (but see also ``-colonly`` below).
|
||||
|
||||
The option ``-convcol`` will create a `class_convexpolygonshape` instead of
|
||||
a `class_concavepolygonshape`. Unlike triangle meshes which can be concave,
|
||||
The option ``-convcol`` will create a `convexpolygonshape` instead of
|
||||
a `concavepolygonshape`. Unlike triangle meshes which can be concave,
|
||||
a convex shape can only accurately represent a shape that doesn't have any
|
||||
concave angles (a pyramid is convex, but a hollow box is concave). Due to this,
|
||||
convex collision shapes are generally not suited for level geometry. When
|
||||
@ -456,22 +456,22 @@ enough for collisions. This can create physics glitches and slow down the engine
|
||||
unnecessarily.
|
||||
|
||||
To solve this, the ``-colonly`` modifier exists. It will remove the mesh upon
|
||||
importing and will create a `class_staticbody` collision instead.
|
||||
importing and will create a `staticbody` collision instead.
|
||||
This helps the visual mesh and actual collision to be separated.
|
||||
|
||||
The option ``-convcolonly`` works in a similar way, but will create a `class_convexpolygonshape` instead.
|
||||
The option ``-convcolonly`` works in a similar way, but will create a `convexpolygonshape` instead.
|
||||
|
||||
The option ``-colonly`` can also be used with Blender's empty objects.
|
||||
On import, it will create a `class_staticbody` with
|
||||
On import, it will create a `staticbody` with
|
||||
a collision node as a child. The collision node will have one of a number of predefined shapes,
|
||||
depending on Blender's empty draw type:
|
||||
|
||||
.. image:: img/3dimp_BlenderEmptyDrawTypes.png
|
||||
|
||||
- Single arrow will create a `class_rayshape`.
|
||||
- Cube will create a `class_boxshape`.
|
||||
- Image will create a `class_planeshape`.
|
||||
- Sphere (and the others not listed) will create a `class_sphereshape`.
|
||||
- Single arrow will create a `rayshape`.
|
||||
- Cube will create a `boxshape`.
|
||||
- Image will create a `planeshape`.
|
||||
- Sphere (and the others not listed) will create a `sphereshape`.
|
||||
|
||||
When possible, **try to use a few primitive collision shapes** instead of triangle
|
||||
mesh or convex shapes. Primitive shapes often have the best performance and
|
||||
@ -498,18 +498,18 @@ Create a VehicleBody (-vehicle)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
A mesh node with the ``-vehicle`` suffix will be imported as a child to a
|
||||
`class_VehicleBody` node.
|
||||
`VehicleBody` node.
|
||||
|
||||
Create a VehicleWheel (-wheel)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
A mesh node with the ``-wheel`` suffix will be imported as a child to a
|
||||
`class_VehicleWheel` node.
|
||||
`VehicleWheel` node.
|
||||
|
||||
Rigid Body (-rigid)
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
A mesh node with the ``-rigid`` suffix will be imported as a `class_RigidBody`.
|
||||
A mesh node with the ``-rigid`` suffix will be imported as a `RigidBody`.
|
||||
|
||||
Animation loop (-loop, -cycle)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -41,7 +41,7 @@ gdscript GDScript
|
||||
effect = AudioServer.get_bus_effect(idx, 0)
|
||||
```
|
||||
|
||||
The audio recording is handled by the `class_AudioEffectRecord` resource
|
||||
The audio recording is handled by the `AudioEffectRecord` resource
|
||||
which has three methods:
|
||||
`get_recording()`,
|
||||
`is_recording_active()`,
|
||||
|
@ -67,7 +67,7 @@ Another reason to use an Autoload can be that you want to reuse the same method
|
||||
or data across many scenes.
|
||||
|
||||
In the case of functions, you can create a new type of ``Node`` that provides
|
||||
that feature for an individual scene using the `class_name
|
||||
that feature for an individual scene using the `name
|
||||
<doc_gdscript_basics_class_name>` keyword in GDScript.
|
||||
|
||||
When it comes to data, you can either:
|
||||
@ -95,7 +95,7 @@ Auto-loaded nodes can simplify your code in some cases:
|
||||
|
||||
Until Godot 3.1, another use was just for convenience: autoloads have a global
|
||||
variable for their name generated in GDScript, allowing you to call them from
|
||||
any script file in your project. But now, you can use the ``class_name`` keyword
|
||||
any script file in your project. But now, you can use the ``name`` keyword
|
||||
instead to get auto-completion for a type in your entire project.
|
||||
|
||||
.. note::
|
||||
|
@ -156,7 +156,7 @@ Browsers do not allow arbitrarily **entering full screen**. The same goes for
|
||||
**capturing the cursor**. Instead, these actions have to occur as a response to
|
||||
a JavaScript input event. In Godot, this means entering full screen from within
|
||||
a pressed input event callback such as ``_input`` or ``_unhandled_input``.
|
||||
Querying the `class_Input` singleton is not sufficient, the relevant
|
||||
Querying the `Input` singleton is not sufficient, the relevant
|
||||
input event must currently be active.
|
||||
|
||||
For the same reason, the full screen project setting doesn't work unless the
|
||||
@ -288,11 +288,11 @@ languages integrated into Godot.
|
||||
The value of the last JavaScript statement is converted to a GDScript value and
|
||||
returned by ``eval()`` under certain circumstances:
|
||||
|
||||
* JavaScript ``number`` is returned as GDScript `class_float`
|
||||
* JavaScript ``boolean`` is returned as GDScript `class_bool`
|
||||
* JavaScript ``string`` is returned as GDScript `class_String`
|
||||
* JavaScript ``number`` is returned as GDScript `float`
|
||||
* JavaScript ``boolean`` is returned as GDScript `bool`
|
||||
* JavaScript ``string`` is returned as GDScript `String`
|
||||
* JavaScript ``ArrayBuffer``, ``TypedArray`` and ``DataView`` are returned as
|
||||
GDScript `class_PoolByteArray`
|
||||
GDScript `PoolByteArray`
|
||||
|
||||
::
|
||||
|
||||
|
@ -143,10 +143,10 @@ known as "echo" events). This is because the operating system never sends "echo"
|
||||
events for controller input in the first place.
|
||||
|
||||
If you want controller buttons to send echo events, you will have to generate
|
||||
`class_InputEvent` objects by code and parse them using
|
||||
`InputEvent` objects by code and parse them using
|
||||
`Input.parse_input_event()`
|
||||
at regular intervals. This can be accomplished
|
||||
with the help of a `class_Timer` node.
|
||||
with the help of a `Timer` node.
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
@ -8,8 +8,8 @@ Introduction
|
||||
|
||||
Godot has a simple serialization API based on Variant. It's used for
|
||||
converting data types to an array of bytes efficiently. This API is used
|
||||
in the functions ``get_var`` and ``store_var`` of `class_File`
|
||||
as well as the packet APIs for `class_PacketPeer`. This format
|
||||
in the functions ``get_var`` and ``store_var`` of `File`
|
||||
as well as the packet APIs for `PacketPeer`. This format
|
||||
is *not* used for binary scenes and resources.
|
||||
|
||||
Packet specification
|
||||
|
@ -15,7 +15,7 @@ scale as the game grows more complex.
|
||||
.. note::
|
||||
|
||||
If you're looking to save user configuration, you can use the
|
||||
`class_ConfigFile` class for this purpose.
|
||||
`ConfigFile` class for this purpose.
|
||||
|
||||
Identify persistent objects
|
||||
---------------------------
|
||||
|
@ -15,8 +15,8 @@ in Godot using matrices. It is not a full in-depth guide to matrices.
|
||||
Transformations are most of the time applied as translation, rotation,
|
||||
and scale, so we will focus on how to represent those with matrices.
|
||||
|
||||
Most of this guide focuses on 2D, using `class_Transform2D` and
|
||||
`class_Vector2`, but the way things work in 3D is very similar.
|
||||
Most of this guide focuses on 2D, using `Transform2D` and
|
||||
`Vector2`, but the way things work in 3D is very similar.
|
||||
|
||||
.. note:: As mentioned in the previous tutorial, it is important to
|
||||
remember that in Godot, the Y axis points *down* in 2D.
|
||||
@ -175,19 +175,19 @@ are in charge of representing rotation, scale, and/or shearing
|
||||
called the *basis* of the transformation matrix. The terms "basis"
|
||||
and "basis vectors" are important to know.
|
||||
|
||||
You might have noticed that `class_Transform2D` actually
|
||||
has three `class_Vector2` values: `x`, `y`, and `origin`.
|
||||
You might have noticed that `Transform2D` actually
|
||||
has three `Vector2` values: `x`, `y`, and `origin`.
|
||||
The `origin` value is not part of the basis, but it is part of the
|
||||
transform, and we need it to represent position. From now on we'll
|
||||
keep track of the origin vector in all examples. You can think of
|
||||
origin as another column, but it's often better to think of it as
|
||||
completely separate.
|
||||
|
||||
Note that in 3D, Godot has a separate `class_Basis` structure
|
||||
for holding the three `class_Vector3` values of the basis,
|
||||
Note that in 3D, Godot has a separate `Basis` structure
|
||||
for holding the three `Vector3` values of the basis,
|
||||
since the code can get complex and it makes sense to separate
|
||||
it from `class_Transform` (which is composed of one
|
||||
`class_Basis` and one extra `class_Vector3` for the origin).
|
||||
it from `Transform` (which is composed of one
|
||||
`Basis` and one extra `Vector3` for the origin).
|
||||
|
||||
Translating the transformation matrix
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -257,7 +257,7 @@ Shearing the transformation matrix (advanced)
|
||||
|
||||
You may have noticed that a transform has more degrees of freedom than
|
||||
the combination of the above actions. The basis of a 2D transformation
|
||||
matrix has four total numbers in two `class_Vector2` values, while
|
||||
matrix has four total numbers in two `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*.
|
||||
|
||||
@ -330,12 +330,12 @@ Practical applications of transforms
|
||||
------------------------------------
|
||||
|
||||
In actual projects, you will usually be working with transforms inside
|
||||
transforms by having multiple `class_Node2D` or `class_Spatial`
|
||||
transforms by having multiple `Node2D` or `Spatial`
|
||||
nodes parented to each other.
|
||||
|
||||
However, sometimes it's very useful to manually calculate the values we
|
||||
need. We will go over how you could use `class_Transform2D` or
|
||||
`class_Transform` to manually calculate transforms of nodes.
|
||||
need. We will go over how you could use `Transform2D` or
|
||||
`Transform` to manually calculate transforms of nodes.
|
||||
|
||||
Converting positions between transforms
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -502,8 +502,8 @@ One of the great things about transformation matrices is that they
|
||||
work very similarly between 2D and 3D transformations.
|
||||
All the code and formulas used above for 2D work the same in 3D,
|
||||
with 3 exceptions: the addition of a third axis, that each
|
||||
axis is of type `class_Vector3`, and also that Godot stores
|
||||
the `class_Basis` separately from the `class_Transform`,
|
||||
axis is of type `Vector3`, and also that Godot stores
|
||||
the `Basis` separately from the `Transform`,
|
||||
since the math can get complex and it makes sense to separate it.
|
||||
|
||||
All of the concepts for how translation, rotation, scale, and shearing
|
||||
@ -518,7 +518,7 @@ If you would like, it's a good idea to play around with transforms
|
||||
to get an understanding of how they work. Godot allows you to edit
|
||||
3D transform matrices directly from the inspector. You can download
|
||||
this project which has colored lines and cubes to help visualize the
|
||||
`class_Basis` vectors and the origin in both 2D and 3D:
|
||||
`Basis` vectors and the origin in both 2D and 3D:
|
||||
https://github.com/godotengine/godot-demo-projects/tree/master/misc/matrix_transform
|
||||
|
||||
.. note:: Spatial's "Matrix" section in Godot 3.2's inspector
|
||||
@ -547,7 +547,7 @@ useful, except for trivial cases.
|
||||
|
||||
In 3D we do not typically use angles, we either use a transformation basis
|
||||
(used pretty much everywhere in Godot), or we use quaternions. Godot can
|
||||
represent quaternions using the `class_Quat` struct. My suggestion
|
||||
represent quaternions using the `Quat` struct. My suggestion
|
||||
to you is to completely ignore how they work under-the-hood, because
|
||||
they are very complicated and unintuitive.
|
||||
|
||||
|
@ -21,7 +21,7 @@ Global scope versus RandomNumberGenerator class
|
||||
-----------------------------------------------
|
||||
|
||||
Godot exposes two ways to generate random numbers: via *global scope* methods or
|
||||
using the `class_RandomNumberGenerator` class.
|
||||
using the `RandomNumberGenerator` class.
|
||||
|
||||
Global scope methods are easier to set up, but they don't offer as much control.
|
||||
|
||||
@ -321,7 +321,7 @@ time, or anything else.
|
||||
|
||||
To achieve this, you can use random *noise* functions. Noise functions are
|
||||
especially popular in procedural generation to generate realistic-looking
|
||||
terrain. Godot provides `class_opensimplexnoise` for this, which supports
|
||||
terrain. Godot provides `opensimplexnoise` for this, which supports
|
||||
1D, 2D, 3D, and 4D noise. Here's an example with 1D noise:
|
||||
|
||||
gdscript GDScript
|
||||
|
@ -93,7 +93,7 @@ In Godot, this back-to-front order is determined by:
|
||||
- The order of objects in the scene tree.
|
||||
- The Z index of objects.
|
||||
- The canvas layer.
|
||||
- `class_YSort` nodes.
|
||||
- `YSort` nodes.
|
||||
|
||||
.. note::
|
||||
|
||||
|
@ -12,9 +12,9 @@ This guide explains:
|
||||
Godot provides many kinds of collision shapes, with different performance and
|
||||
accuracy tradeoffs.
|
||||
|
||||
You can define the shape of a `class_PhysicsBody` by adding one or more
|
||||
You can define the shape of a `PhysicsBody` by adding one or more
|
||||
`CollisionShapes` as child nodes. Note that you must
|
||||
add a `class_Shape` *resource* to collision shape nodes in the Inspector
|
||||
add a `Shape` *resource* to collision shape nodes in the Inspector
|
||||
dock.
|
||||
|
||||
.. note::
|
||||
@ -27,10 +27,10 @@ Primitive collision shapes
|
||||
|
||||
Godot provides the following primitive collision shape types:
|
||||
|
||||
- `class_BoxShape`
|
||||
- `class_SphereShape`
|
||||
- `class_CapsuleShape`
|
||||
- `class_CylinderShape`
|
||||
- `BoxShape`
|
||||
- `SphereShape`
|
||||
- `CapsuleShape`
|
||||
- `CylinderShape`
|
||||
|
||||
You can represent the collision of most smaller objects using one or more
|
||||
primitive shapes. However, for more complex objects, such as a large ship or a
|
||||
|
@ -157,7 +157,7 @@ The imported resource has a specific type, so the editor can know which property
|
||||
slot it belongs to. This allows drag and drop from the FileSystem dock to a
|
||||
property in the Inspector.
|
||||
|
||||
In our case it's a `class_SpatialMaterial`, which can be applied to 3D
|
||||
In our case it's a `SpatialMaterial`, which can be applied to 3D
|
||||
objects.
|
||||
|
||||
.. note:: If you need to import different types from the same extension, you
|
||||
|
@ -9,8 +9,8 @@ resources, although you can use the feature to change the inspector widgets for
|
||||
built-in types. You can design custom controls for specific properties, entire
|
||||
objects, and even separate controls associated with particular datatypes.
|
||||
|
||||
This guide explains how to use the `class_EditorInspectorPlugin` and
|
||||
`class_EditorProperty` classes to create a custom interface for integers,
|
||||
This guide explains how to use the `EditorInspectorPlugin` and
|
||||
`EditorProperty` classes to create a custom interface for integers,
|
||||
replacing the default behavior with a button that generates random values
|
||||
between 0 and 99.
|
||||
|
||||
@ -31,7 +31,7 @@ Let's assume you've called your plugin folder ``my_inspector_plugin``. If so,
|
||||
you should end up with a new ``addons/my_inspector_plugin`` folder that contains
|
||||
two files: ``plugin.cfg`` and ``plugin.gd``.
|
||||
|
||||
As before, ``plugin.gd`` is a script extending `class_EditorPlugin` and you
|
||||
As before, ``plugin.gd`` is a script extending `EditorPlugin` and you
|
||||
need to introduce new code for its ``_enter_tree`` and ``_exit_tree`` methods.
|
||||
To set up your inspector plugin, you must load its script, then create and add
|
||||
the instance by calling ``add_inspector_plugin()``. If the plugin is disabled,
|
||||
@ -65,14 +65,14 @@ Interacting with the inspector
|
||||
------------------------------
|
||||
|
||||
To interact with the inspector dock, your ``MyInspectorPlugin.gd`` script must
|
||||
extend the `class_EditorInspectorPlugin` class. This class provides several
|
||||
extend the `EditorInspectorPlugin` class. This class provides several
|
||||
virtual methods that affect how the inspector handles properties.
|
||||
|
||||
To have any effect at all, the script must implement the ``can_handle()``
|
||||
method. This function is called for each edited `class_Object` and must
|
||||
method. This function is called for each edited `Object` and must
|
||||
return ``true`` if this plugin should handle the object or its properties.
|
||||
|
||||
.. note:: This includes any `class_Resource` attached to the object.
|
||||
.. note:: This includes any `Resource` attached to the object.
|
||||
|
||||
You can implement four other methods to add controls to the inspector at
|
||||
specific positions. The ``parse_begin()`` and ``parse_end()`` methods are called
|
||||
@ -84,7 +84,7 @@ As the editor parses the object, it calls the ``parse_category()`` and
|
||||
``parse_property()`` methods. There, in addition to ``add_custom_control()``,
|
||||
you can call both ``add_property_editor()`` and
|
||||
``add_property_editor_for_multiple_properties()``. Use these last two methods to
|
||||
specifically add `class_EditorProperty`-based controls.
|
||||
specifically add `EditorProperty`-based controls.
|
||||
|
||||
gdscript GDScript
|
||||
|
||||
@ -117,12 +117,12 @@ gdscript GDScript
|
||||
Adding an interface to edit properties
|
||||
--------------------------------------
|
||||
|
||||
The `class_EditorProperty` class is a special type of `class_Control`
|
||||
The `EditorProperty` class is a special type of `Control`
|
||||
that can interact with the inspector dock's edited objects. It doesn't display
|
||||
anything but can house any other control nodes, including complex scenes.
|
||||
|
||||
There are three essential parts to the script extending
|
||||
`class_EditorProperty`:
|
||||
`EditorProperty`:
|
||||
|
||||
1. You must define the ``_init()`` method to set up the control nodes'
|
||||
structure.
|
||||
@ -190,5 +190,5 @@ gdscript GDScript
|
||||
```
|
||||
|
||||
Using the example code above you should be able to make a custom widget that
|
||||
replaces the default `class_SpinBox` control for integers with a
|
||||
`class_Button` that generates random values.
|
||||
replaces the default `SpinBox` control for integers with a
|
||||
`Button` that generates random values.
|
||||
|
@ -81,7 +81,7 @@ The script file
|
||||
Upon creation of the plugin, the dialog will automatically open the
|
||||
EditorPlugin script for you. The script has two requirements that you cannot
|
||||
change: it must be a ``tool`` script, or else it will not load properly in the
|
||||
editor, and it must inherit from `class_EditorPlugin`.
|
||||
editor, and it must inherit from `EditorPlugin`.
|
||||
|
||||
.. warning::
|
||||
|
||||
@ -135,15 +135,15 @@ custom behavior.
|
||||
|
||||
To create a new node type, you can use the function
|
||||
`add_custom_type()` from the
|
||||
`class_EditorPlugin` class. This function can add new types to the editor
|
||||
`EditorPlugin` class. This function can add new types to the editor
|
||||
(nodes or resources). However, before you can create the type, you need a script
|
||||
that will act as the logic for the type. While that script doesn't have to use
|
||||
the ``tool`` keyword, it can be added so the script runs in the editor.
|
||||
|
||||
For this tutorial, we'll create a simple button that prints a message when
|
||||
clicked. For that, we'll need a simple script that extends from
|
||||
`class_Button`. It could also extend
|
||||
`class_BaseButton` if you prefer:
|
||||
`Button`. It could also extend
|
||||
`BaseButton` if you prefer:
|
||||
|
||||
gdscript GDScript
|
||||
|
||||
|
@ -3,23 +3,23 @@
|
||||
Visual Shader plugins
|
||||
=====================
|
||||
|
||||
Visual Shader plugins are used to create custom `class_VisualShader` nodes
|
||||
Visual Shader plugins are used to create custom `VisualShader` nodes
|
||||
in GDScript.
|
||||
|
||||
The creation process is different from usual editor plugins. You do not need to
|
||||
create a ``plugin.cfg`` file to register it; instead, create and save a script
|
||||
file and it will be ready to use, provided the custom node is registered with
|
||||
``class_name``.
|
||||
``name``.
|
||||
|
||||
This short tutorial will explain how to make a Perlin-3D noise node (original
|
||||
code from this `GPU noise shaders plugin
|
||||
<https://github.com/curly-brace/Godot-3.0-Noise-Shaders/blob/master/assets/gpu_noise_shaders/classic_perlin3d.tres>`_.
|
||||
|
||||
Create a Sprite and assign a `class_ShaderMaterial` to its material slot:
|
||||
Create a Sprite and assign a `ShaderMaterial` to its material slot:
|
||||
|
||||
.. image:: img/visual_shader_plugins_start.png
|
||||
|
||||
Assign `class_VisualShader` to the shader slot of the material:
|
||||
Assign `VisualShader` to the shader slot of the material:
|
||||
|
||||
.. image:: img/visual_shader_plugins_start2.png
|
||||
|
||||
@ -27,7 +27,7 @@ Don't forget to change its mode to "CanvasItem" (if you are using a Sprite):
|
||||
|
||||
.. image:: img/visual_shader_plugins_start3.png
|
||||
|
||||
Create a script which derives from `class_VisualShaderNodeCustom`. This is
|
||||
Create a script which derives from `VisualShaderNodeCustom`. This is
|
||||
all you need to initialize your plugin.
|
||||
|
||||
::
|
||||
|
@ -75,7 +75,7 @@ be instantiated with `GDScript.New()`.
|
||||
GDScript MyGDScript = (GDScript) GD.Load("res://path_to_gd_file.gd");
|
||||
Object myGDScriptNode = (Godot.Object) MyGDScript.New(); // This is a Godot.Object
|
||||
|
||||
Here we are using an `class_Object`, but you can use type conversion like
|
||||
Here we are using an `Object`, but you can use type conversion like
|
||||
explained in `doc_c_sharp_features_type_conversion_and_casting`.
|
||||
|
||||
Accessing fields
|
||||
@ -118,7 +118,7 @@ and `Object.Set()`. The first argument is the name of the field you want to acce
|
||||
|
||||
Keep in mind that when setting a field value you should only use types the
|
||||
GDScript side knows about.
|
||||
Essentially, you want to work with built-in types as described in `doc_gdscript` or classes extending `class_Object`.
|
||||
Essentially, you want to work with built-in types as described in `doc_gdscript` or classes extending `Object`.
|
||||
|
||||
Calling methods
|
||||
---------------
|
||||
|
@ -3,7 +3,7 @@
|
||||
Evaluating expressions
|
||||
======================
|
||||
|
||||
Godot provides an `class_Expression` class you can use to evaluate expressions.
|
||||
Godot provides an `Expression` class you can use to evaluate expressions.
|
||||
|
||||
An expression can be:
|
||||
|
||||
@ -198,7 +198,7 @@ The output from the script will be::
|
||||
Built-in functions
|
||||
------------------
|
||||
|
||||
Most methods available in the `class_@GDScript` scope are available in the
|
||||
Most methods available in the `@GDScript` scope are available in the
|
||||
Expression class, even if no base instance is bound to the expression.
|
||||
The same parameters and return types are available.
|
||||
|
||||
|
@ -166,9 +166,9 @@ too. Some Examples:
|
||||
In GDScript, only base types (int, float, String and PoolArray types)
|
||||
are passed by value to functions (value is copied). Everything else
|
||||
(instances, Arrays, Dictionaries, etc) is passed as reference. Classes
|
||||
that inherit `class_Reference` (the default if nothing is specified)
|
||||
that inherit `Reference` (the default if nothing is specified)
|
||||
will be freed when not used, but manual memory management is allowed too
|
||||
if inheriting manually from `class_Object`.
|
||||
if inheriting manually from `Object`.
|
||||
|
||||
.. note::
|
||||
|
||||
|
@ -303,7 +303,7 @@ Literals
|
||||
+--------------------------+----------------------------------------+
|
||||
| ``"""Hello"""`` | Multiline string |
|
||||
+--------------------------+----------------------------------------+
|
||||
| ``@"Node/Label"`` | `class_NodePath` or StringName |
|
||||
| ``@"Node/Label"`` | `NodePath` or StringName |
|
||||
+--------------------------+----------------------------------------+
|
||||
| ``$NodePath`` | Shorthand for ``get_node("NodePath")`` |
|
||||
+--------------------------+----------------------------------------+
|
||||
@ -567,7 +567,7 @@ assign to it::
|
||||
.. note::
|
||||
|
||||
The bracket syntax can be used to access properties of any
|
||||
`class_Object`, not just Dictionaries. Keep in mind it will cause a
|
||||
`Object`, not just Dictionaries. Keep in mind it will cause a
|
||||
script error when attempting to index a non-existing property. To avoid
|
||||
this, use the `Object.get()` and
|
||||
`Object.set()` methods instead.
|
||||
@ -616,7 +616,7 @@ Valid types are:
|
||||
- Engine classes (Node, Resource, Reference, etc.).
|
||||
- Constant names if they contain a script resource (``MyScript`` if you declared ``const MyScript = preload("res://my_script.gd")``).
|
||||
- Other classes in the same script, respecting scope (``InnerClass.NestedClass`` if you declared ``class NestedClass`` inside the ``class InnerClass`` in the same scope).
|
||||
- Script classes declared with the ``class_name`` keyword.
|
||||
- Script classes declared with the ``name`` keyword.
|
||||
|
||||
Casting
|
||||
^^^^^^^
|
||||
@ -1084,7 +1084,7 @@ Registering named classes
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
You can give your class a name to register it as a new type in Godot's
|
||||
editor. For that, you use the ``class_name`` keyword. You can optionally add
|
||||
editor. For that, you use the ``name`` keyword. You can optionally add
|
||||
a comma followed by a path to an image, to use it as an icon. Your
|
||||
class will then appear with its new icon in the editor::
|
||||
|
||||
@ -1097,7 +1097,7 @@ class will then appear with its new icon in the editor::
|
||||
|
||||
.. warning::
|
||||
|
||||
If the script is located in the ``res://addons/`` directory, ``class_name``
|
||||
If the script is located in the ``res://addons/`` directory, ``name``
|
||||
will only cause the node to show up in the **Create New Node** dialog if
|
||||
the script is part of an *enabled* editor plugin. See `doc_making_plugins`
|
||||
for more information.
|
||||
@ -1377,12 +1377,12 @@ See `doc_running_code_in_the_editor` for more information.
|
||||
Memory management
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
If a class inherits from `class_Reference`, then instances will be
|
||||
If a class inherits from `Reference`, then instances will be
|
||||
freed when no longer in use. No garbage collector exists, just
|
||||
reference counting. By default, all classes that don't define
|
||||
inheritance extend **Reference**. If this is not desired, then a class
|
||||
must inherit `class_Object` manually and must call ``instance.free()``. To
|
||||
avoid reference cycles that can't be freed, a `class_WeakRef` function is
|
||||
must inherit `Object` manually and must call ``instance.free()``. To
|
||||
avoid reference cycles that can't be freed, a `WeakRef` function is
|
||||
provided for creating weak references. Here is an example:
|
||||
|
||||
::
|
||||
@ -1429,7 +1429,7 @@ to. To create custom signals for a class, use the ``signal`` keyword.
|
||||
Game Programming Patterns ebook.
|
||||
|
||||
You can connect these signals to methods the same way you connect built-in
|
||||
signals of nodes like `class_Button` or `class_RigidBody`.
|
||||
signals of nodes like `Button` or `RigidBody`.
|
||||
|
||||
In the example below, we connect the ``health_depleted`` signal from a
|
||||
``Character`` node to a ``Game`` node. When the ``Character`` node emits the
|
||||
|
@ -659,7 +659,7 @@ Class declaration
|
||||
If the code is meant to run in the editor, place the ``tool`` keyword on the
|
||||
first line of the script.
|
||||
|
||||
Follow with the `class_name` if necessary. You can turn a GDScript file into a
|
||||
Follow with the `name` if necessary. You can turn a GDScript file into a
|
||||
global type in your project using this feature. For more information, see
|
||||
`doc_gdscript`.
|
||||
|
||||
|
@ -107,7 +107,7 @@ Currently you can use three types of… types:
|
||||
1. `Built-in <doc_gdscript_builtin_types>`
|
||||
2. Core classes and nodes (``Object``, ``Node``, ``Area2D``,
|
||||
``Camera2D``, etc.)
|
||||
3. Your own custom classes. Look at the new `class_name <doc_gdscript_basics_class_name>`
|
||||
3. Your own custom classes. Look at the new `name <doc_gdscript_basics_class_name>`
|
||||
feature to register types in the editor.
|
||||
|
||||
.. note::
|
||||
@ -126,7 +126,7 @@ script you want to use as a type in a constant:
|
||||
const Rifle = preload("res://player/weapons/Rifle.gd")
|
||||
var my_rifle: Rifle
|
||||
|
||||
The second method is to use the ``class_name`` keyword when you create.
|
||||
The second method is to use the ``name`` keyword when you create.
|
||||
For the example above, your Rifle.gd would look like this:
|
||||
|
||||
::
|
||||
@ -134,7 +134,7 @@ For the example above, your Rifle.gd would look like this:
|
||||
extends Node2D
|
||||
class_name Rifle
|
||||
|
||||
If you use ``class_name``, Godot registers the Rifle type globally in
|
||||
If you use ``name``, Godot registers the Rifle type globally in
|
||||
the editor, and you can use it anywhere, without having to preload it
|
||||
into a constant:
|
||||
|
||||
|
@ -50,11 +50,11 @@ AutoLoad
|
||||
--------
|
||||
|
||||
You can create an AutoLoad to load a scene or a script that inherits from
|
||||
`class_Node`.
|
||||
`Node`.
|
||||
|
||||
.. note::
|
||||
|
||||
When autoloading a script, a `class_Node` will be created and the script will be
|
||||
When autoloading a script, a `Node` will be created and the script will be
|
||||
attached to it. This node will be added to the root viewport before any
|
||||
other scenes are loaded.
|
||||
|
||||
|
@ -10,9 +10,9 @@ Label nodes are great for displaying basic text, but they have limits. If you wa
|
||||
to change the color of the text, or its alignment, that change affects all of the
|
||||
text in the Label node. You can't have only one part of the text be one color, or
|
||||
only one part of the text be centered. To get around this limitation you would use
|
||||
a `class_RichTextLabel`.
|
||||
a `RichTextLabel`.
|
||||
|
||||
`class_RichTextLabel` allows the display of complex text markup in a Control.
|
||||
`RichTextLabel` allows the display of complex text markup in a Control.
|
||||
It has a built-in API for generating the markup, but can also parse a BBCode.
|
||||
|
||||
Note that the BBCode tags can also be used, to some extent, in the
|
||||
@ -216,8 +216,8 @@ of the rainbow, ``val`` is the value of the rainbow.
|
||||
Custom BBCode tags and text effects
|
||||
-----------------------------------
|
||||
|
||||
You can extend the `class_RichTextEffect` resource type to create your own custom
|
||||
BBCode tags. You begin by extending the `class_RichTextEffect` resource type. Add
|
||||
You can extend the `RichTextEffect` resource type to create your own custom
|
||||
BBCode tags. You begin by extending the `RichTextEffect` resource type. Add
|
||||
the ``tool`` prefix to your GDScript file if you wish to have these custom effects run
|
||||
within the editor itself. The RichTextLabel does not need to have a script attached,
|
||||
nor does it need to be running in ``tool`` mode. The new effect will be activable in
|
||||
@ -238,7 +238,7 @@ use the name of the file to determine what the BBCode tag should be.
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This is where the logic of each effect takes place and is called once per character
|
||||
during the draw phase of text rendering. This passes in a `class_CharFXTransform`
|
||||
during the draw phase of text rendering. This passes in a `CharFXTransform`
|
||||
object, which holds a few variables to control how the associated character is rendered:
|
||||
|
||||
- ``identity`` specifies which custom effect is being processed. You should use that for
|
||||
@ -252,7 +252,7 @@ object, which holds a few variables to control how the associated character is r
|
||||
- ``offset`` is an offset position relative to where the given character should render under
|
||||
normal circumstances.
|
||||
- ``color`` is the color of a given character.
|
||||
- Finally, ``env`` is a `class_Dictionary` of parameters assigned to a given custom
|
||||
- Finally, ``env`` is a `Dictionary` of parameters assigned to a given custom
|
||||
effect. You can use `get()` with an optional default value
|
||||
to retrieve each parameter, if specified by the user. For example ``[custom_fx spread=0.5
|
||||
color=#FFFF00]test[/custom_fx]`` would have a float ``spread`` and Color ``color``
|
||||
|
Loading…
Reference in New Issue
Block a user