-
Notifications
You must be signed in to change notification settings - Fork 1
normal_bar
Inherits: base_bar
Inherited By: normal_bar_values
normal_bar acts like a normal bar which means that adding a value will just add the value and subtracting a value will just subtract it. To use this bar make sure to set the maximum value at the scene start otherwise the default value will be used as maximum which is 1. Optionally you can set the current value as well if you want to at the scene start otherwise its value will be 0.
Return Type | Name |
---|---|
void | subtract( int value ) |
void subtract ( int value )
This method subtracts the _value_cur with the given value. While subtracting the _value_cur property will never go below 0. It will stop at 0.
Note: If the parameter value given is less than and equal to 0 then the calculation will be ignored and nothing will happen. Only positive values greater than 0 will be allowed for calculation.
SomeScript.gd
extends Node
@export var bar: COP_BaseBar
func _ready() -> void:
bar.set_max(10)
bar.set_current(10) # Optional: If you also want to set the current value at the start but it is NOT necessary if NOT needed
## This method hurts the character with the given value.
func hurt(value: int) -> void:
bar.subtract(value) # Removing health by subtracting bar's current value
## This method heals the character with the given value.
func heal(value: int) -> void:
bar.add(value) # Adding health by adding to bar's current value
## This method checks if the character is dead or NOT.
func is_dead() -> bool:
return is_depleted()
## This method returns the health's normal value so that the UI bar can be synced.
func get_health_normal() -> float:
return bar.get_normal() # The health's normal value which is the bar's normal value
- Tutorial Bar
- Tutorial Debug
- Tutorial Instantiate Object
- Tutorial Pool
- Tutorial Timer
- Tutorial Update Manager
- Tutorial Variable Creator
- Bars
- Debugs
- Maths
- Pools
- Resources
- Fixed Vars
- Managers
- Observers
- Vars
- Script Templates
- Timers
- Updates