2017-09-12 22:42:36 +02:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-03-01 01:44:37 +01:00
<class name= "bool" version= "4.1" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 22:42:36 +02:00
<brief_description >
2023-04-28 01:35:33 +02:00
A built-in boolean type.
2017-09-12 22:42:36 +02:00
</brief_description>
<description >
2023-04-28 01:35:33 +02: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 16:07:26 +02:00
[codeblocks]
[gdscript]
2023-04-28 01:35:33 +02:00
if can_shoot:
launch_bullet()
2020-07-31 16:07:26 +02:00
[/gdscript]
[csharp]
2023-04-28 01:35:33 +02:00
if (canShoot)
2020-07-31 16:07:26 +02:00
{
2023-04-28 01:35:33 +02:00
launchBullet();
2020-07-31 16:07:26 +02:00
}
[/csharp]
[/codeblocks]
2023-04-28 01:35:33 +02: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 16:07:26 +02:00
[codeblocks]
[gdscript]
2023-04-28 01:35:33 +02:00
if bullets > 0 and not is_reloading:
launch_bullet()
2020-01-13 17:19:03 +01:00
2023-04-28 01:35:33 +02:00
if bullets == 0 or is_reloading:
play_clack_sound()
2020-07-31 16:07:26 +02:00
[/gdscript]
[csharp]
2023-04-28 01:35:33 +02:00
if (bullets > 0 & & !isReloading)
2020-07-31 16:07:26 +02:00
{
2023-04-28 01:35:33 +02:00
launchBullet();
2020-07-31 16:07:26 +02:00
}
2023-04-28 01:35:33 +02:00
if (bullets == 0 || isReloading)
2020-07-31 16:07:26 +02:00
{
2023-04-28 01:35:33 +02:00
playClackSound();
2020-07-31 16:07:26 +02:00
}
[/csharp]
[/codeblocks]
2017-09-12 22:42:36 +02:00
</description>
<tutorials >
</tutorials>
2021-09-21 04:49:02 +02:00
<constructors >
<constructor name= "bool" >
2021-07-30 15:28:05 +02:00
<return type= "bool" />
2020-11-09 17:46:03 +01:00
<description >
Constructs a default-initialized [bool] set to [code]false[/code].
</description>
2021-09-21 04:49:02 +02:00
</constructor>
<constructor name= "bool" >
2021-07-30 15:28:05 +02:00
<return type= "bool" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "from" type= "bool" />
2017-09-12 22:42:36 +02:00
<description >
2020-11-09 17:46:03 +01:00
Constructs a [bool] as a copy of the given [bool].
2017-09-12 22:42:36 +02:00
</description>
2021-09-21 04:49:02 +02:00
</constructor>
<constructor name= "bool" >
2021-07-30 15:28:05 +02:00
<return type= "bool" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "from" type= "float" />
2017-09-12 22:42:36 +02:00
<description >
2023-04-28 01:35:33 +02: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 22:42:36 +02:00
</description>
2021-09-21 04:49:02 +02:00
</constructor>
<constructor name= "bool" >
2021-07-30 15:28:05 +02:00
<return type= "bool" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "from" type= "int" />
2017-09-12 22:42:36 +02:00
<description >
2023-04-28 01:35:33 +02: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 22:42:36 +02:00
</description>
2021-09-21 04:49:02 +02:00
</constructor>
</constructors>
<operators >
<operator name= "operator !=" >
2021-07-30 15:28:05 +02:00
<return type= "bool" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "right" type= "bool" />
2020-11-10 14:16:20 +01:00
<description >
2021-01-06 01:13:11 +01: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 14:16:20 +01:00
</description>
2021-09-21 04:49:02 +02:00
</operator>
<operator name= "operator <" >
2021-07-30 15:28:05 +02:00
<return type= "bool" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "right" type= "bool" />
2020-11-10 14:16:20 +01:00
<description >
2021-09-21 04:49:02 +02:00
Returns [code]true[/code] if the left operand is [code]false[/code] and the right operand is [code]true[/code].
2020-11-10 14:16:20 +01:00
</description>
2021-09-21 04:49:02 +02:00
</operator>
<operator name= "operator ==" >
2021-07-30 15:28:05 +02:00
<return type= "bool" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "right" type= "bool" />
2020-11-10 14:16:20 +01:00
<description >
2021-01-06 01:13:11 +01: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 14:16:20 +01:00
</description>
2021-09-21 04:49:02 +02:00
</operator>
<operator name= "operator >" >
2021-07-30 15:28:05 +02:00
<return type= "bool" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "right" type= "bool" />
2020-11-10 14:16:20 +01:00
<description >
2021-09-21 04:49:02 +02:00
Returns [code]true[/code] if the left operand is [code]true[/code] and the right operand is [code]false[/code].
2020-11-10 14:16:20 +01:00
</description>
2021-09-21 04:49:02 +02:00
</operator>
</operators>
2017-09-12 22:42:36 +02:00
</class>