I am trying to create a camera using an animator, as I here that is the "accepted" way now. I have it working fine, except the camera's control logic is buried within the OnEvent. I assume this is fine. My question comes when I need to add more OnEvents for other nodes, like my player, how do I handle that? Do I temporarily turn off the cameras event receiver while processing other input? Or should I create a master event receiver and pass events to this camera/player/etc?
Thanks
Animators and EventReceivers
Re: Animators and EventReceivers
Events get passed on unless the eventreceiver returns true (which means event is done). So depends on your receivers if you need to disable the other one or if they can run in parallel. Or maybe your animator can take a scenenode pointer and can control both the camera and the player and you would want to move the animator around instead.
There are just different solutions and it's hard to give general hints. You don't even have to use animators - I often just use update functions instead if it fits the rest of the program architecture better.
There are just different solutions and it's hard to give general hints. You don't even have to use animators - I often just use update functions instead if it fits the rest of the program architecture better.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Animators and EventReceivers
You can switch event receivers by "setEventReceiver". Or you can use a event receiver that act like a filter wich decides to wich sub-event receiver sends an event.
For example
or
of course you can register a sub event receiver in your own event receiver.
irrlicht is very flexibile with events. You can use the approach you prefer. At a certain level you need also how irrlicht internally handle things (you must know how certain events are generated and how to stop other events) but this is in general not limiting.
For example
Code: Select all
onEvent(SEvent & event)
{
if(character1->isActive())
return character1->onEvent(event);
if(character2->isActive())
return character2->onEvent(event);
return false;
}
Code: Select all
onEvent(SEvent & event)
{
if(character1)
if(charater1->onEvent(event)
return true;
if(character2)
if(charater2->onEvent(event)
return true;
return false;
}
Code: Select all
onEvent(SEvent & event)
{
if(registeredReceiver !=0)
return registeredReceiver->OnEvent(event);
return false;
}
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me