I'm trying to develop a topview chopper game done with Irrlicht. Here's a clue :
With time, the MyEventReceiver is getting bigger and bigger to a point that its unreadable. I'm trying to clean up code by creating a custom SceneNode that implements IEventReceiver::OnEvent(SEvent).
I've been through the tutorial on this subject and created pretty much the same class. Each time MyEventReceiver is notified of an event, it gives it to the CPlayerSceneNode::OnEvent(SEvent) which returns true if treated. I'm only checking for simple inputs to move the node according to which arrow key is pressed.
Here's my problem, I went through some debugging and I know that :
When pressing the arrow key, the CPlayerSceneNode::OnEvent(SEvent) gets notified. GOOD
If the pressed key is an arrow, the proper code gets executed. GOOD
According to the arrow key, the node's position gets updated. STILL GOOD
But even if the node's position is changing, there's no visual feedback. The mesh stays at its initial position. Not that good...
Here's a part of the code
Code: Select all
bool CPlayerSceneNode::OnEvent(SEvent event)
{
bool consumed = false;
if(event.EventType == EET_KEY_INPUT_EVENT && event.KeyInput.PressedDown)
{
vector3df pos = this->getPosition();
switch(event.KeyInput.Key)
{
case KEY_LEFT:
{
pos.X--;
consumed = true;
}
break;
case KEY_RIGHT:
{
pos.X++;
consumed = true;
}
break;
}
this->setPosition(pos);
}
return consumed;
}
Code: Select all
IVideoDriver * driver = SceneManager->getVideoDriver();
driver->setMaterial(m_material);
driver->drawMeshBuffer(m_mesh->getMeshBuffer(0));