Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent (SEvent event)
{
if (node != 0 && event.EventType == EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
case KEY_KEY_S:
{
core::vector3df v = node->getPosition();
while(event.KeyInput.PressedDown)
{
v.Y += event.KeyInput.Key == KEY_KEY_W ? 2.0f : -2.0f;
node->setPosition(v);
}
}
return true;
switch(event.KeyInput.Key)
{
case KEY_KEY_D:
case KEY_KEY_A:
{
core::vector3df v = node->getPosition();
while(event.KeyInput.PressedDown)
{
v.X += event.KeyInput.Key == KEY_KEY_D ? 2.0f : -2.0f;
node->setPosition(v);
}
}
}
return true;
}
}
return false;
}
};