Simple Event Receiver 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
Dark Logan
Posts: 11
Joined: Thu Dec 15, 2005 3:43 pm
Location: Hessen, Germany
Contact:

Simple Event Receiver Question

Post by Dark Logan »

Is it possible to have a EventReceiver that creates an Irrlicht Device and passes itself as EventReceiver?

I tried it with createDevice( ..., this, ...) and with IrrlichtDevice->setEventReceiver( this). Both doesn't work.

I just browsed the web and the forums and didn't find anything about that.

Any idea or must I have two classes?

Thanks, Dark Logan

P.S.: I use it for GameState Managment. Virtual GameState derives from IEventReceiver. And the actual State from Virtual GameState. Is the problem within this?
Last edited by Dark Logan on Sun Feb 05, 2006 9:48 am, edited 1 time in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Sure you can. What do you mean it when you say it doesn't work. Is it failing to compile, or does it not run like you expect?

Travis
Dark Logan
Posts: 11
Joined: Thu Dec 15, 2005 3:43 pm
Location: Hessen, Germany
Contact:

Post by Dark Logan »

Code: Select all

#ifndef INTRO_H
#define INTRO_H

#include <irrlicht.h>

#include "GameManager.h"
#include "GameState.h"

class Intro : public GameState {
      public:
             Intro();
             ~Intro();
             
             bool OnEvent( SEvent Event);
             
             bool run();
             
      protected:
                IrrlichtDevice* Device;
                IVideoDriver* VideoDriver;
                ITexture* IntroPicture;
};

#endif
This is the Header for my Intro Screen. It doesn't compile, it says:
In constructor `Intro::Intro()':
`irr::IEventReceiver' is an inaccessible base of `Intro'

The constructor looks like this:

Code: Select all

Intro::Intro() {
     Device = createDevice( EDT_SOFTWARE,
                            dimension2d<s32>(800,600),
                            16,
                            true,
                            false,
                            false,
                            0,
                            IRRLICHT_SDK_VERSION);
     VideoDriver = Device->getVideoDriver();
     
     // load IntroPicture
     IntroPicture = VideoDriver->getTexture("./media/startup.bmp");
     
     if( IntroPicture == NULL) {
         GameManager::getInstance()->changeState( NULL);
     }
     
     Device->setEventReceiver( this);
}
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

This is just a simple C++ question/lesson

Usually when you get a compile error it includes a line number. Look at what you are doing on that line and think about the error message carefully... In constructor `Intro::Intro()': `irr::IEventReceiver' is an inaccessible base of `Intro'. Now why would the base class IEventReceiver be inaccessible to a derived class Intro? Ponder that for a while.

For those that are reading this, don't just blurt out the answer. I'm hoping to help Logan.
Dark Logan
Posts: 11
Joined: Thu Dec 15, 2005 3:43 pm
Location: Hessen, Germany
Contact:

Post by Dark Logan »

Well I had to put using namespace irr; in front of it. :oops:
vitek, you help me a lot with this. I think I won't forget about the namespaces again.
Thanks a lot, vitek
Post Reply