Here's another way to do it.
func _input(event):
if event.is_pressed():
var v = Input.get_vector('ui_left', 'ui_right', 'ui_up', 'ui_down')
match v:
Vector2(1, 0):
print('right')
Vector2(-1, 0):
print('left')
Vector2(0, -1):
print('up')
Vector2(0, 1):
print('down')
It has the advantage that you could just use the vector "v" as the argument to spawn_bullet.
func _input(event):
if event.is_pressed():
var v = Input.get_vector('ui_left', 'ui_right', 'ui_up', 'ui_down')
spawn_bullet(v)
However, if two buttons are pressed at the same time, you'll get a vector like "(0.7, 0.7)", so you'll have to check that only one coordinate is set [ (1, 0), etc ] in your spawn_bullet() function. Or just use:
func _input(event):
if event.is_pressed():
var v = Input.get_vector('ui_left', 'ui_right', 'ui_up', 'ui_down')
if v and v == v.floor():
spawn_bullet(v)
Edit: Checking for "v and ..." ensures that unrelated mouse-clicks won't fire a bullet.