Stupid question??? Please help

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
neppyweb
Posts: 22
Joined: Thu Nov 23, 2006 12:44 pm

Stupid question??? Please help

Post by neppyweb »

I have this in declaration
private:
scene::ISceneNode* Terrain;

public:
/* MyEventReceiver(scene::ISceneNode* terrain)
{
// store pointer to terrain so we can change its drawing mode
Terrain = terrain;
}*/
This is for use key to move character
virtual bool OnEvent(SEvent event)
{
// check if user presses the key 'W' or 'D'
if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
{
switch (event.KeyInput.Key)
{
case irr::KEY_KEY_W: // switch wire frame mode
Terrain->setMaterialFlag(video::EMF_WIREFRAME, !Terrain->getMaterial(0).Wireframe);
return true;
case irr::KEY_KEY_D: // toggle detail map
Terrain->setMaterialType(
Terrain->getMaterial(0).MaterialType == video::EMT_SOLID ?
video::EMT_DETAIL_MAP : video::EMT_SOLID);
return true;
}
}
}
I have this code in subroutine
/*MyEventReceiver receiver(terrain);
device->setEventReceiver(&receiver);*/
I have this in main function
MyEventReceiver receiver;
device->setEventReceiver(&receiver);

This program can run
1. to menu and then click the "new game" button (as tutorial 5) to call subroutine (to go to game) but I can't use any buttons to move.

What is different from above code?? Because I have them in my program and the error is occured If I do not comment first and second???

So I want to know what it mean???What should I do???
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Re: Stupid question??? Please help

Post by omar shaaban »

I have this in main function
MyEventReceiver receiver;
device->setEventReceiver(&receiver);
well i think the error is coming bec u cant add the receiver to the terrain u must added in the create device:

Code: Select all

IrrlichtDevice *device =createDevice(EDT_DIRECT3D9, dimension2d<s32>(800, 600), 16,false, false, false, &receiver);
i think so :roll:
Last edited by omar shaaban on Wed Jan 31, 2007 5:04 pm, edited 1 time in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Your event receiver must return false if it doesn't handle the event that is coming in. You should put a return false; as the last line in your OnEvent() function.

Travis
omar shaaban
Posts: 616
Joined: Wed Nov 01, 2006 6:26 pm
Location: Cairo,Egypt
Contact:

Post by omar shaaban »

oops sorry for the wrong answer!!!
Post Reply