Shooter¶
Node creating a level of abstraction in order to fire projectiles.
Inherits : Node2D
Properties¶
Methods¶
Signals¶
- start_attack
Signal emitted when the entity can start attacking (after stop moving for example).
Emitted by :
set_can_shoot()
Received by :_on_start_attack_timeout()
- stop_attack
Signal emitted when the entity should stop attacking (when running for example).
Emitted by :
set_can_shoot()
Received by :_on_stop_attack_timeout()
Description¶
This Node acts as a layer. It’s a layer above the player, and his job is to instance the projectiles.
Such a trick is needed, because if we simply instancied the projectile in the player Node, projectiles would be childrens of the player, and whenever the player move, the projectiles would move also. We need the position of the player and the projectiles to be independant.
This Node also handle the timer for the attack speed.
Properties description¶
projectile
¶
Type | Projectile |
Default | null |
Non-Instancied Projectile to shoot. The Shooter will instanciate a new one every time it fires.
can_shoot
¶
Type | bool |
Default | true |
State of the Shooter : if it can shoot (not running for example), it is true
, else false
.
Methods description¶
init(shooting_entity, projectile_to_shoot, attck_spd=1, hit_run=false)
¶
Arguments
|
Method to initialize the object with the value needed.
_ready()
¶
This function simply call the set_can_shoot()
function at startup time, in order to send the signal.
set_can_shoot(cs)
¶
Arguments
|
can_shoot
property.Emitted signals
|
_on_start_attack_timeout(collider)
¶
start_attack
signal is emitted._on_Recharging_timeout()
and start the timer according to attack_speed
for the next projectile.Receives signals
|
_on_stop_attack_timeout()
¶
stop_attack
signal is emitted.Receives signals
|
_on_Recharging_timeout()
¶
Main timer, used for timing every time a projectile is fired, based on attack_speed
.
entity
exist, it instanciate a new projectile
and fire it.entity
does not exist anymore (may be killed), it does nothing until the last fired projectile is freed (because if we free before, the child projectile will also be freed).Receives signals
|