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.
thomas55
Post
by thomas55 » Sat Sep 24, 2005 10:20 pm
ive read though the keybord input page at irrforge but my input code dont work heres my code:
Code: Select all
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
{
irrDevice->closeDevice();
break;
}
}
return false;
}
};
and heres the errors i get
2 C:\Irrlicht\Game\keyinput.h expected class-name before '{' token
4 C:\Irrlicht\Game\keyinput.h `OnEvent' declared as a `virtual' field
4 C:\Irrlicht\Game\keyinput.h expected `;' before '(' token
19 C:\Irrlicht\Game\keyinput.h expected `;' before '}' token
im using dev c++ can someone please help me
Guest
Post
by Guest » Sat Sep 24, 2005 10:25 pm
could you post the whole file?
Guest
Post
by Guest » Sat Sep 24, 2005 10:27 pm
That code is correct. I think you forgot to include irrlicht.h
Guest
Post
by Guest » Sat Sep 24, 2005 10:36 pm
we dont know if he does not post the whole file, thats why i asked for it.
thomas55
Post
by thomas55 » Sat Sep 24, 2005 10:49 pm
i fogot irrlicht.h
thomas55
Post
by thomas55 » Sat Sep 24, 2005 10:52 pm
#include <irrlicht.h>
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
{
irrDevice->closeDevice();
break;
}
}
return false;
}
};
i still ge tthe same errors
thomas55
Post
by thomas55 » Sat Sep 24, 2005 10:58 pm
also for the moment that is the whole file
Guest
Post
by Guest » Sat Sep 24, 2005 10:59 pm
you forgot to use namespaces:
using namespace irr;
using namespace core;
using namespace video;
using namespace scene;
using namespace gui;
using namespace io;
that are all namespaces.
thomas55
Post
by thomas55 » Sat Sep 24, 2005 11:05 pm
still the same errors when i added all of the namespaces
Guest
Post
by Guest » Sat Sep 24, 2005 11:14 pm
this is what i did:
1. created a new devc++ console project
2. pasted your code
3. got the same errors
then after i used the namespaces all errors where gone.
thomas55
Post
by thomas55 » Sat Sep 24, 2005 11:17 pm
1 more error
23 C:\Irrlicht\Game\Keyinput.h `irrDevice' undeclared (first use this function)
heres the code:
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace video;
using namespace scene;
using namespace gui;
using namespace io;
#pragma comment(lib, "Engine.lib")
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
{
irrDevice->closeDevice();
break;
}
}
return false;
}
};
thomas55
Post
by thomas55 » Sat Sep 24, 2005 11:19 pm
it compiles when i take this out
thomas55
Post
by thomas55 » Sat Sep 24, 2005 11:24 pm
it compiles but the esc key doesent quit the game
thomas55
Post
by thomas55 » Sat Sep 24, 2005 11:25 pm
i got it working with the
irrDevice->closeDevice();
break;
sorry about double post
Guest
Post
by Guest » Sat Sep 24, 2005 11:29 pm
with:
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace video;
using namespace scene;
using namespace gui;
using namespace io;
#pragma comment(lib, "Engine.lib")
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == irr::EET_KEY_INPUT_EVENT && !event.KeyInput.PressedDown)
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
{
irrDevice->closeDevice();
break;
}
}
return false;
}
};
im getting the errors i got at the start again