I tried to search a complete tutorial for irrlicht engine, but i just can't find one, the one on the forum is too short and i have problems with it. when i go through the third chapter, the compiler just can't compile the program for me. it give me this error.
74 G:\Desktop\Irrlicht Engine\main.cpp cannot declare variable `rv' to be of type `MyEventReceiver'
This is the key receiver, can anybody help me with that and find me a better tutorial?? Thanks
irrlicht complete tutorial
Did you download the source of Irrlicht? And then run the example solution?
Or did you copy and paste the code from the internet (wiki) into your own project?
You should download the package and load the example solution. It should work, as the environment is set up to compile.
Or did you copy and paste the code from the internet (wiki) into your own project?
You should download the package and load the example solution. It should work, as the environment is set up to compile.
I can hear birds chirping
I live in the Eye of Insanity.
I live in the Eye of Insanity.
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
You should post the whole error message.
But since i have telepathic capabilities, it can tell you that have to change the signature of the event receiver's OnEvent method to:
But since i have telepathic capabilities, it can tell you that have to change the signature of the event receiver's OnEvent method to:
Code: Select all
bool OnEvent(const irr::SEvent& event)
"Whoops..."
The error message is like this.
32 G:\Desktop\irrlicht\main.cpp cannot declare variable `rv' to be of type `MyEventReceiver'
32 G:\Desktop\irrlicht\main.cpp because the following virtual functions are abstract:
351 F:\irrlicht-1.5.1\include\IEventReceiver.h virtual bool irr::IEventReceiver::OnEvent(const irr::SEvent&)
Here is the code of my sample program
32 G:\Desktop\irrlicht\main.cpp cannot declare variable `rv' to be of type `MyEventReceiver'
32 G:\Desktop\irrlicht\main.cpp because the following virtual functions are abstract:
351 F:\irrlicht-1.5.1\include\IEventReceiver.h virtual bool irr::IEventReceiver::OnEvent(const irr::SEvent&)
Here is the code of my sample program
Code: Select all
#include <cstdlib>
#include <iostream>
#include <irrlicht.h>
using namespace std;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace gui;
bool keys[irr::KEY_KEY_CODES_COUNT];
class MyEventReceiver : public IEventReceiver {
public:
bool OnEvent(SEvent event) {
if(event.EventType == irr::EET_KEY_INPUT_EVENT){
keys[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
return false;
}
};
#pragma comment(lib, Irrlicht.lib);
int main()
{
IrrlichtDevice* device = createDevice(EDT_OPENGL);
IVideoDriver* video = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
MyEventReceiver rv;
device->setEventReceiver(&rv);
for(int x=0; x<irr::KEY_KEY_CODES_COUNT; x++) keys[x] = false;
ISceneNode* cube = smgr->addCubeSceneNode();
cube->setPosition(vector3df(0,0,5));
while(device->run() && device)
{
if(keys[KEY_KEY_W]) {
cube->setPosition(cube->getPosition()+vector3df(0,0,5));
}
video->beginScene(true, true, video::SColor(255,0,0,255));
smgr->drawAll();
video->endScene();
}
return EXIT_SUCCESS;
}
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am