mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-05 23:40:07 +01:00
* General proofreading for grammar and spelling * General formatting * Addition of appropriate literals where appropriate, i.e. `&"foo"` for `StringName` cases and `^"foo/bar"` for `NodePath` cases
19 lines
404 B
GDScript
19 lines
404 B
GDScript
extends Node2D
|
|
|
|
var bullet := preload("Bullet.tscn")
|
|
|
|
func _unhandled_input(input_event: InputEvent) -> void:
|
|
if input_event.is_action_pressed(&"fire"):
|
|
fire()
|
|
|
|
|
|
func fire() -> void:
|
|
if not $CooldownTimer.is_stopped():
|
|
return
|
|
|
|
$CooldownTimer.start()
|
|
var new_bullet := bullet.instantiate()
|
|
new_bullet.position = global_position
|
|
new_bullet.direction = owner.look_direction
|
|
add_child(new_bullet)
|