i'm having a little trouble understanding how to get UserInput on Irrlicht.
considering this segment:
Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
// This is the one method that we have to implement
virtual bool OnEvent(const SEvent& event)
{
// Remember whether each key is down or up
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
// This is used to check whether a key is being held down
virtual bool IsKeyDown(EKEY_CODE keyCode) const
{
return KeyIsDown[keyCode];
}
MyEventReceiver()
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown[i] = false;
}
private:
// We use this array to store the current state of each key
bool KeyIsDown[KEY_KEY_CODES_COUNT];
};
1- so IEventReceiver is just a class, right? so, i should create an object from it, which will receive instructions from Irrlicht when something happens? and then i just check the object every time i want to know if some user input happened?
2-why, in this example, a derivated class was created? is it just to know if a key is being held down? can't Irrlicht check that by itself?
3-thanks in advance?
thanks in advance