feat: added fire input binding
This commit is contained in:
parent
a7e14fb109
commit
3b8ce8ca53
|
@ -16,6 +16,7 @@ void TunnelsPlayer::_bind_methods() {
|
||||||
#define CLASSNAME TunnelsPlayer
|
#define CLASSNAME TunnelsPlayer
|
||||||
GDFUNCTION_ARGS(horizontal_move_input, "event", "value");
|
GDFUNCTION_ARGS(horizontal_move_input, "event", "value");
|
||||||
GDFUNCTION_ARGS(vertical_move_input, "event", "value");
|
GDFUNCTION_ARGS(vertical_move_input, "event", "value");
|
||||||
|
GDFUNCTION_ARGS(fire_pressed, "event", "value");
|
||||||
GDPROPERTY_HINTED(camera_rotation_ramp, Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, "Curve");
|
GDPROPERTY_HINTED(camera_rotation_ramp, Variant::OBJECT, PROPERTY_HINT_RESOURCE_TYPE, "Curve");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +95,7 @@ void TunnelsPlayer::process_camera_rotation(double delta_time) {
|
||||||
void TunnelsPlayer::setup_player_input(PlayerInput *input) {
|
void TunnelsPlayer::setup_player_input(PlayerInput *input) {
|
||||||
input->listen_to(PlayerInput::Listener("move_left", "move_right", this, "horizontal_move_input"));
|
input->listen_to(PlayerInput::Listener("move_left", "move_right", this, "horizontal_move_input"));
|
||||||
input->listen_to(PlayerInput::Listener("move_forward", "move_backward", this, "vertical_move_input"));
|
input->listen_to(PlayerInput::Listener("move_forward", "move_backward", this, "vertical_move_input"));
|
||||||
|
input->listen_to(PlayerInput::Listener("fire", this, "fire_pressed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Node *TunnelsPlayer::to_node() {
|
Node *TunnelsPlayer::to_node() {
|
||||||
|
@ -108,6 +110,10 @@ void TunnelsPlayer::vertical_move_input(Ref<InputEvent> event, float value) {
|
||||||
this->move_input.y = value;
|
this->move_input.y = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TunnelsPlayer::fire_pressed(Ref<InputEvent> event, float value) {
|
||||||
|
this->character->set_firing(value != 0);
|
||||||
|
}
|
||||||
|
|
||||||
void TunnelsPlayer::initialize_character() {
|
void TunnelsPlayer::initialize_character() {
|
||||||
Ref<PackedScene> player_scene = ResourceLoader::get_singleton()->load("res://player_character.tscn");
|
Ref<PackedScene> player_scene = ResourceLoader::get_singleton()->load("res://player_character.tscn");
|
||||||
// check if the player scene is a valid player character
|
// check if the player scene is a valid player character
|
||||||
|
|
|
@ -34,6 +34,7 @@ public:
|
||||||
|
|
||||||
void horizontal_move_input(Ref<InputEvent> event, float value);
|
void horizontal_move_input(Ref<InputEvent> event, float value);
|
||||||
void vertical_move_input(Ref<InputEvent> event, float value);
|
void vertical_move_input(Ref<InputEvent> event, float value);
|
||||||
|
void fire_pressed(Ref<InputEvent> event, float value);
|
||||||
|
|
||||||
void initialize_character();
|
void initialize_character();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue