Code: Select all
class MyEventReceiver : public IEventReceiver{public: virtual bool OnEvent(SEvent event) {
If the key 'W' or 'S' was left up, we get the position of the scene node, and modify the Y coordinate a little bit. So if you press 'W', the node moves up, and if you press 'S' it moves down.
-->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; }}<--
The event receiver for moving a scene node is ready. So lets just create an Irrlicht Device and the scene node we want to move. We also create some other additional scene nodes, to show that there are also some different possibilities to move and animate scene nodes.
int main()
On the plus side, though, it's correct in the code that's supplied. Just thought I'd mention this so it can get fixed.