Event Reciver...

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
KAHIMA
Posts: 19
Joined: Sun Mar 01, 2009 7:44 am

Event Reciver...

Post by KAHIMA »

Sorry 4 bad english... I already make some 3d visualization , and to rendering the terrain i use class and constructor using IEventReceiver and in the same file i make user interface, and detect some button clicked.
In the terrain function i use

Code: Select all

        // create event receiver
	MyEventReceiver receiver(terrain);
	device->setEventReceiver(&receiver);
and the user interface i nedd to use

Code: Select all

MyEventReceiver receiver;
	device->setEventReceiver(&receiver);
How can I make the class and constructor?
The constructor that I already make

Code: Select all

class MyEventReceiver : public IEventReceiver
{
public:

	MyEventReceiver(scene::ISceneNode* terrain)
	{
		Terrain = terrain;
	}
}
and there's error message
error C2512: 'MyEventReceiver' : no appropriate default constructor available
[/code]
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Re: Event Reciver...

Post by vitek »

KAHIMA wrote:

Code: Select all

MyEventReceiver receiver;
device->setEventReceiver(&receiver);

Code: Select all

class MyEventReceiver : public IEventReceiver
{
public:

	MyEventReceiver(scene::ISceneNode* terrain)
	{
		Terrain = terrain;
	}
}
and there's error message
error C2512: 'MyEventReceiver' : no appropriate default constructor available
Your MyEventReceiver class doesn't have a constructor that takes no parameters. If you must use your MyEventReceiver in both places (i.e., you can't create a new class), then you have to add a constructor that takes no parameters, or you need to pass a terrain to the constructor.

Travis
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

or you can pass 0 (NULL) as default to the constructor:

Code: Select all

class MyEventReceiver : public IEventReceiver
{
public:

   MyEventReceiver(scene::ISceneNode* terrain = 0)
   {
      Terrain = terrain;
   }
} 
if you do something to the terrain, then you'll have to check if it's != 0, of course... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply