I yesterday picked up 0.4, and man am I impressed. It's come a long way.
Anyways, I was reading through the tutorials and I was wondering how to make the program exit when the user presses Escape. This is a simple solution I came up with. Let me know what you think, or if there are any problems!
Code: Select all
class InputQuitOnEscape : public IEventReceiver
{
public:
InputQuitOnEscape() : IEventReceiver(), device(NULL)
{
}
void SetDevice(IrrlichtDevice * d)
{
device = d;
}
virtual bool OnEvent(SEvent event)
{
if(device) {
if(event.EventType == EET_KEY_INPUT_EVENT) {
if(event.KeyInput.Key == KEY_ESCAPE) {
device->closeDevice();
return true;
}
}
}
return false;
}
private:
IrrlichtDevice * device;
};