Code: Select all
bool wpressed;
bool spressed;
bool walk;
class CEventReceiver_eg3 : public IEventReceiver
{
public:
CEventReceiver_eg3()
{
}
~CEventReceiver_eg3()
{
}
bool OnEvent(SEvent event)
{
if(event.EventType == EET_KEY_INPUT_EVENT&&event.KeyInput.PressedDown == true)
{
if(event.KeyInput.Key == KEY_KEY_W)
{
wpressed=true;
walk=true;
}
if(event.KeyInput.Key == KEY_KEY_S)
{
spressed=true;
walk=true;
}
}
else if(event.KeyInput.PressedDown == false)
{
wpressed=false;
spressed=false;
walk=false;
}
return false;
}
};
Code: Select all
while (device->run())
{
if (wpressed==true)
{
plnode->setPosition(vector3df(plnode->getPosition().X + 2 , plnode->getPosition().Y,plnode->getPosition().Z));
}
else if (spressed==true)
{
plnode->setPosition(vector3df(plnode->getPosition().X -2 , plnode->getPosition().Y,plnode->getPosition().Z));
}
if(walk=true)
{
plnode->setFrameLoop(250,800);
plnode->setAnimationSpeed(40);
}
}