Game Development Reference
In-Depth Information
Action
Action has some helpers to create and store Triggers as well as provide a way for
the InputManager to quickly update the state of the input system.
class Action
{
private:
std::vector<Trigger*> _triggers;
bool _isTriggered;
public:
bool enabled;
Action();
~Action();
template <class T>
T* CreateTrigger()
{
auto t = new T();
_triggers.push_back(t);
return t;
};
void Update(InputManager *input);
bool IsTriggered() { return _isTriggered; }
};
The update method is pretty straightforward. It loops through the triggers linked to it
until it finds the first one to trigger, at which point it sets its own _isTriggered flag
to signal to the code watching the action that the user has done whatever input is
necessary.
void Action::Update(InputManager *input)
{
Search WWH ::




Custom Search