Code: Select all
Unhandled exception at 0x1010af46 in Client.exe: 0xC0000005: Access violation reading location 0x00000004.
Event.h
Code: Select all
#include "Global.h"
#include <iostream>
class CGameEventReceiver : public IEventReceiver
{
private:
IrrlichtDevice* Device;
public:
CGameEventReceiver(IrrlichtDevice* device);
virtual bool OnEvent(const SEvent& event);
};
IEventReceiver* createGameEventReceiver(IrrlichtDevice* device);
Code: Select all
#include "Event.h"
bool CGameEventReceiver::OnEvent(const SEvent &event)
{
if (event.EventType == EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
{
switch (event.KeyInput.Key)
{
case KEY_ESCAPE:
Device->closeDevice();
default:
break;
}
}
return false;
}
CGameEventReceiver::CGameEventReceiver(IrrlichtDevice* device)
{
Device = device;
}
IEventReceiver* createGameEventReceiver(IrrlichtDevice* device)
{
CGameEventReceiver er(device);
return &er;
}
Code: Select all
IEventReceiver* er = createGameEventReceiver(Device);
Device->setEventReceiver(er);