I'd just like to ask some simple questions about the event receiver, and how it works.
I was looking at the "movement" tutorial, and I created a simple version of it, with just a single TestSceneNode. I wanted to see how I could move the block around with the keyboard. In the tutorial there is this code:
Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (node != 0 && event.EventType == irr::EET_KEY_INPUT_EVENT &&
!event.KeyInput.PressedDown)
{
switch(event.KeyInput.Key)
{
case KEY_KEY_W:
case KEY_KEY_S
{
core::vector3df v = node->getPosition();
v.Y += event.KeyInput.Key == KEY_KEY_W ? 2.0f : -2.0f;
node->setPosition(v);
}
return true;
}
}
return false;
}
};
I just can't work out how that would move the block? Most C++ seems quite logical, where to me this just seems quite confusing! Just another bit of syntax im yet to learn i guess, heh.
I'd also like to be able to move the block around when a key is held down, or the left/right with the A and D keys. I played around with a few functions, like "event.KeyInput.PressedDown" or something similar but had no luck.
Thanks in advance!