bool keys[]
Salutes
Ok I do this right after main starts:
CIrrLichtEvent * keyHandler;
keyHandler->Init();
If I just create it (CIrrLichtEvent keyHandler; = no pointer) i get unresolved external symbol.
I use pointer for now, and it compiles, but it doesnt work. Do I need to run something each frame? Simply typing this in the loop do not work:
if(keyHandler->IsKeyDown(KEY_KEY_W))
players[0]->gold+=50;
I must have missed something... Plz help any1. It also warns me about keyHandler not being initialized. But it is right?
Beam
Ok I do this right after main starts:
CIrrLichtEvent * keyHandler;
keyHandler->Init();
If I just create it (CIrrLichtEvent keyHandler; = no pointer) i get unresolved external symbol.
I use pointer for now, and it compiles, but it doesnt work. Do I need to run something each frame? Simply typing this in the loop do not work:
if(keyHandler->IsKeyDown(KEY_KEY_W))
players[0]->gold+=50;
I must have missed something... Plz help any1. It also warns me about keyHandler not being initialized. But it is right?
Beam
Re: to use multi-key and mouse-button
That is probably all nice and working code, but how do I use it the loop? Tried checking for IsKeyDown but that didn't work.lifetree wrote: GOOD LUCK!
Try to implement a method like below
//-------------------------------------
void CIrrLichtEvent::ProcessInput()
{
if (IsKeyDown(KEY_KEY_W))
{
actions...
}
if (IsKeyDown(KEY_KEY_A))
{
actions...
}
...
}
//-------------------------------------
Then in the Irrlicht main loop call it
to handle your events. For example:
...
while(device->run())
if (device->isWindowActive())
{
irrEventRec.ProcessInput();
...
//-------------------------------------
void CIrrLichtEvent::ProcessInput()
{
if (IsKeyDown(KEY_KEY_W))
{
actions...
}
if (IsKeyDown(KEY_KEY_A))
{
actions...
}
...
}
//-------------------------------------
Then in the Irrlicht main loop call it
to handle your events. For example:
...
while(device->run())
if (device->isWindowActive())
{
irrEventRec.ProcessInput();
...
i found something useful
ok oddly enough i had a problem where i'd press right and the thing would perform as expected.. btw im using the first method mentioned in this post. when i pressed left or up it did nothing. i loaded up my debugger and put a watch on event.KeyInput.Key and lo and behold it turns out that the event handler in the engine reads my keyboard's left arrow key as KEY_KEY_A. if you're having problems like this i suggest you use a debugger to watch te event.KeyInput.Key variable to see what your keys on your keyboard are actuall y doing in the engine.
hope this helps someone. see ya
hope this helps someone. see ya
Thanks, kaless!!
awesome tutorial thing, and finally my key input works but now, its always returning true, which means i cant send input to the camera
does this mean i need to do
//OnEvent
if(event.EventType == irr::EET_KEY_INPUT_EVENT
&& event.KeyInput.Key != KEY_UP && event.KeyInput.Key != KEY_DOWN && event.KeyInput.Key != KEY_LEFT && event.KeyInput.Key != KEY_RIGHT){
keys[event.KeyInput.Key] = event.KeyInput.PressedDown;
return true;
}
?
Thanks!
EDIT: i can probably just do "return false;" instead of "return true;" so the camera cares too.
-dudMan
awesome tutorial thing, and finally my key input works but now, its always returning true, which means i cant send input to the camera
does this mean i need to do
//OnEvent
if(event.EventType == irr::EET_KEY_INPUT_EVENT
&& event.KeyInput.Key != KEY_UP && event.KeyInput.Key != KEY_DOWN && event.KeyInput.Key != KEY_LEFT && event.KeyInput.Key != KEY_RIGHT){
keys[event.KeyInput.Key] = event.KeyInput.PressedDown;
return true;
}
?
Thanks!
EDIT: i can probably just do "return false;" instead of "return true;" so the camera cares too.
-dudMan
Wtf thats certainly not true... Accessing outside of the array bounds would yeild a memory access error.Boogle wrote:Hehe, not in C++! It happily references as far outside of your array as you want.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Goodpoint
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
When i used it with OpenGL and GLut, dont using Irrlicht i used 2 functions to "receive" the event.
one for KeyDown, and another to KeyUp, so i dont need to run false for all keys all the time.
And glutIgnoreKeyRepeat(true); so i dont run the event when nothing was changed, if you press a key and dont release it, the KeyUp will be called 1 time, all that you need is check for your key, if it is set up or down in your bool key[] array.
There is an way to do that in Irrlicht?
There is keyup(), keydown(), and glutIgnoreKeyRepeat(true) like functions?
Ty
sosssego
one for KeyDown, and another to KeyUp, so i dont need to run false for all keys all the time.
And glutIgnoreKeyRepeat(true); so i dont run the event when nothing was changed, if you press a key and dont release it, the KeyUp will be called 1 time, all that you need is check for your key, if it is set up or down in your bool key[] array.
There is an way to do that in Irrlicht?
There is keyup(), keydown(), and glutIgnoreKeyRepeat(true) like functions?
Ty
sosssego