diff options
Diffstat (limited to 'doc/classes')
-rw-r--r-- | doc/classes/Engine.xml | 16 | ||||
-rw-r--r-- | doc/classes/KinematicBody2D.xml | 2 | ||||
-rw-r--r-- | doc/classes/bool.xml | 33 |
3 files changed, 48 insertions, 3 deletions
diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml index 04e203793b..53ddde0e4a 100644 --- a/doc/classes/Engine.xml +++ b/doc/classes/Engine.xml @@ -41,7 +41,7 @@ <return type="int"> </return> <description> - Returns the total number of frames drawn. + Returns the total number of frames drawn. If the render loop is disabled with [code]--disable-render-loop[/code] via command line, this returns [code]0[/code]. See also [method get_idle_frames]. </description> </method> <method name="get_frames_per_second" qualifiers="const"> @@ -51,6 +51,13 @@ Returns the frames per second of the running game. </description> </method> + <method name="get_idle_frames" qualifiers="const"> + <return type="int"> + </return> + <description> + Returns the total number of frames passed since engine initialization which is advanced on each [b]idle frame[/b], regardless of whether the render loop is enabled. See also [method get_frames_drawn]. + </description> + </method> <method name="get_license_info" qualifiers="const"> <return type="Dictionary"> </return> @@ -72,6 +79,13 @@ Returns the main loop object (see [MainLoop] and [SceneTree]). </description> </method> + <method name="get_physics_frames" qualifiers="const"> + <return type="int"> + </return> + <description> + Returns the total number of frames passed since engine initialization which is advanced on each [b]physics frame[/b]. + </description> + </method> <method name="get_physics_interpolation_fraction" qualifiers="const"> <return type="float"> </return> diff --git a/doc/classes/KinematicBody2D.xml b/doc/classes/KinematicBody2D.xml index 1de75cd71b..470d8db47a 100644 --- a/doc/classes/KinematicBody2D.xml +++ b/doc/classes/KinematicBody2D.xml @@ -17,7 +17,7 @@ <return type="Vector2"> </return> <description> - Returns the normal vector of the floor. + Returns the normal vector of the floor. </description> </method> <method name="get_floor_velocity" qualifiers="const"> diff --git a/doc/classes/bool.xml b/doc/classes/bool.xml index 533963b460..ba6a932d4f 100644 --- a/doc/classes/bool.xml +++ b/doc/classes/bool.xml @@ -4,7 +4,38 @@ Boolean built-in type. </brief_description> <description> - Boolean built-in type. + Boolean is a built-in type. It can represent any data type that is either a true or false value. You can think of it as an switch with on or off (1 or 0) setting . It's often used as part of programming logic in condition statements like [code]if[/code] statements. + [b]Note:[/b] In a code below [code]if can_shoot[/code] is equivalent of [code]if can_shoot == true[/code]. It is good practice to follow the natural spoken language structure when possible. Use [code]if can_shoot[/code] rather than [code]if can_shoot == true[/code] and use [code]if not can_shoot[/code] rather than [code]if can_shoot == false[/code]. + [codeblock] + var can_shoot = true + + func shoot(): + if can_shoot: + # Perform shooting actions here. + [/codeblock] + The following code will only create a bullet if both conditions are met: action "shoot" is pressed and if [code]can_shoot[/code] is [code]true[/code]. + [b]Note:[/b] [code]Input.is_action_pressed("shoot")[/code] is also a boolean that is [code]true[/code] when "shoot" is pressed and [code]false[/code] when "shoot" isn't pressed. + [codeblock] + var can_shoot = true + + func shoot(): + if can_shoot and Input.is_action_pressed("shoot"): + create_bullet() + [/codeblock] + The following code will set [code]can_shoot[/code] to [code]false[/code] and start a timer. This will prevent player from shooting until the timer runs out. Next [code]can_shoot[/code] will be set to [code]true[/code] again allowing player to shoot once again. + [codeblock] + var can_shoot = true + onready var cool_down = $CoolDownTimer + + func shoot(): + if can_shoot and Input.is_action_pressed("shoot"): + create_bullet() + can_shoot = false + cool_down.start() + + func _on_CoolDownTimer_timeout(): + can_shoot = true + [/codeblock] </description> <tutorials> </tutorials> |