2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-07-06 08:08:05 +00:00
<class name= "bool" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 20:42:36 +00:00
<brief_description >
2023-04-27 23:35:33 +00:00
A built-in boolean type.
2017-09-12 20:42:36 +00:00
</brief_description>
<description >
2023-04-27 23:35:33 +00:00
A [bool] is always one of two values: [code]true[/code] or [code]false[/code], similar to a switch that is either on or off. Booleans are used in programming for logic in condition statements.
Booleans can be directly used in [code]if[/code] and [code]elif[/code] statements. You don't need to add [code]== true[/code] or [code]== false[/code]:
2020-07-31 14:07:26 +00:00
[codeblocks]
[gdscript]
2023-04-27 23:35:33 +00:00
if can_shoot:
launch_bullet()
2020-07-31 14:07:26 +00:00
[/gdscript]
[csharp]
2023-04-27 23:35:33 +00:00
if (canShoot)
2020-07-31 14:07:26 +00:00
{
2023-04-27 23:35:33 +00:00
launchBullet();
2020-07-31 14:07:26 +00:00
}
[/csharp]
[/codeblocks]
2023-04-27 23:35:33 +00:00
Many common methods and operations return [bool]s, for example, [code]shooting_cooldown < = 0.0[/code] may evaluate to [code]true[/code] or [code]false[/code] depending on the number's value.
[bool]s are usually used with the logical operators [code]and[/code], [code]or[/code], and [code]not[/code] to create complex conditions:
2020-07-31 14:07:26 +00:00
[codeblocks]
[gdscript]
2023-04-27 23:35:33 +00:00
if bullets > 0 and not is_reloading:
launch_bullet()
2020-01-13 16:19:03 +00:00
2023-04-27 23:35:33 +00:00
if bullets == 0 or is_reloading:
play_clack_sound()
2020-07-31 14:07:26 +00:00
[/gdscript]
[csharp]
2023-04-27 23:35:33 +00:00
if (bullets > 0 & & !isReloading)
2020-07-31 14:07:26 +00:00
{
2023-04-27 23:35:33 +00:00
launchBullet();
2020-07-31 14:07:26 +00:00
}
2023-04-27 23:35:33 +00:00
if (bullets == 0 || isReloading)
2020-07-31 14:07:26 +00:00
{
2023-04-27 23:35:33 +00:00
playClackSound();
2020-07-31 14:07:26 +00:00
}
[/csharp]
[/codeblocks]
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
</tutorials>
2021-09-21 02:49:02 +00:00
<constructors >
<constructor name= "bool" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2020-11-09 16:46:03 +00:00
<description >
Constructs a default-initialized [bool] set to [code]false[/code].
</description>
2021-09-21 02:49:02 +00:00
</constructor>
<constructor name= "bool" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "from" type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
2020-11-09 16:46:03 +00:00
Constructs a [bool] as a copy of the given [bool].
2017-09-12 20:42:36 +00:00
</description>
2021-09-21 02:49:02 +00:00
</constructor>
<constructor name= "bool" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "from" type= "float" />
2017-09-12 20:42:36 +00:00
<description >
2023-04-27 23:35:33 +00:00
Cast a [float] value to a boolean value. This method will return [code]false[/code] if [code]0.0[/code] is passed in, and [code]true[/code] for all other values.
2017-09-12 20:42:36 +00:00
</description>
2021-09-21 02:49:02 +00:00
</constructor>
<constructor name= "bool" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "from" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2023-04-27 23:35:33 +00:00
Cast an [int] value to a boolean value. This method will return [code]false[/code] if [code]0[/code] is passed in, and [code]true[/code] for all other values.
2017-09-12 20:42:36 +00:00
</description>
2021-09-21 02:49:02 +00:00
</constructor>
</constructors>
<operators >
<operator name= "operator !=" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "bool" />
2020-11-10 13:16:20 +00:00
<description >
2021-01-06 00:13:11 +00:00
Returns [code]true[/code] if two bools are different, i.e. one is [code]true[/code] and the other is [code]false[/code].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator <" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "bool" />
2020-11-10 13:16:20 +00:00
<description >
2021-09-21 02:49:02 +00:00
Returns [code]true[/code] if the left operand is [code]false[/code] and the right operand is [code]true[/code].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator ==" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "bool" />
2020-11-10 13:16:20 +00:00
<description >
2021-01-06 00:13:11 +00:00
Returns [code]true[/code] if two bools are equal, i.e. both are [code]true[/code] or both are [code]false[/code].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator >" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "bool" />
2020-11-10 13:16:20 +00:00
<description >
2021-09-21 02:49:02 +00:00
Returns [code]true[/code] if the left operand is [code]true[/code] and the right operand is [code]false[/code].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
</operators>
2017-09-12 20:42:36 +00:00
</class>