Singletonejada la classe Input

This commit is contained in:
2024-09-28 14:19:00 +02:00
parent fa82758ce1
commit 2767696a3f
19 changed files with 87 additions and 44 deletions

View File

@@ -1,6 +1,27 @@
#include "input.h"
#include <iostream>
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Input *Input::input = nullptr;
// [SINGLETON] Crearemos el objeto input con esta función estática
void Input::init(std::string file)
{
Input::input = new Input(file);
}
// [SINGLETON] Destruiremos el objeto input con esta función estática
void Input::destroy()
{
delete Input::input;
}
// [SINGLETON] Con este método obtenemos el objeto input y podemos trabajar con él
Input *Input::get()
{
return Input::input;
}
// Constructor
Input::Input(std::string file)
{
@@ -47,6 +68,12 @@ Input::Input(std::string file)
buttonInputs.push_back(input_start);
}
// Destructor
Input::~Input()
{
}
// Actualiza el estado del objeto
void Input::update()
{