Singletonejada la classe Input
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user