event handler question

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
Podunk
Posts: 8
Joined: Sat Oct 08, 2005 12:42 am

event handler question

Post by Podunk »

can i, from my main program loop, check a sort of "event queue" array of events, and if this so called "event queue" contains any elements, then call a function which performs some things using the "event queue"


reason being is, I can't figure out how to do things to my array of (IAnimatedMeshSceneNode)s from within the instance of the event reciever class:

Code: Select all

class MyEventReceiver : public IEventReceiver
I know that when instantiating the event reciever object from the event reciever class, i can pass the constructor a pointer to the array of objects, but for some reason i think thats kind of a funky way to do things.


Should I just do everything from within an event reciever class?

I can't seem to make main() my event reciever either :P

Thanks in advance :D
I R noob.
Please don't harp on me for asking noobie questions in the noob forum :P
[SOM]Roberto.

Re: event handler question

Post by [SOM]Roberto. »

Podunk wrote:can i, from my main program loop, check a sort of "event queue" array of events, and if this so called "event queue" contains any elements, then call a function which performs some things using the "event queue"


reason being is, I can't figure out how to do things to my array of (IAnimatedMeshSceneNode)s from within the instance of the event reciever class:

Code: Select all

class MyEventReceiver : public IEventReceiver
I know that when instantiating the event reciever object from the event reciever class, i can pass the constructor a pointer to the array of objects, but for some reason i think thats kind of a funky way to do things.


Should I just do everything from within an event reciever class?

I can't seem to make main() my event reciever either :P

Thanks in advance :D
Why do u use event in main?
Irrlicht events is global system. If u programming under the windows only u must use windows voids...

If u want use irrlicht events u implemented the next example:

//start header
//====================================================================================================
class Start : public IEventReceiver
{
public:
Start() {}
~Start() {}

void Start_running_void();
virtual bool OnEvent(SEvent event);
};

-------------------------------------------------------------------------------------------------------

//main source
#include start.h

Start Start_running;

//====================================================================================================
int main()
{
Start.Start_running_void();
return 0;
}

-------------------------------------------------------------------------------------------------------

//start source
#include start.h


//====================================================================================================
void Start::Start_running_void()
{
Start Start_events;
............
device = createDevice(video::EDT_SOFTWARE, core::dimension2d<s32>(512, 384), 16, false, true, false, &Start_events);
............
}

//====================================================================================================
bool Start::OnEvent(SEvent event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();

switch(event.GUIEvent.EventType)
{
case gui::EGET_BUTTON_CLICKED: //buttons

..................................
}
}
}
-------------------------------------------------------------------------------------------------------

:)

[SOM]Roberto
Podunk
Posts: 8
Joined: Sat Oct 08, 2005 12:42 am

Post by Podunk »

WOW thank you very much for this!

I knew I was thinking bass ackwards ROFL
I R noob.
Please don't harp on me for asking noobie questions in the noob forum :P
Post Reply