Hi,
Ich hab (mal wieder) ein problem mit dem Eventreceiver.
Ich habe folgenden code:
Code:
#include "irrlicht.h"
#include <cstdlib>
#include <iostream>
#define SINGLEPLAYER 1
#define MULTIPLAYER 2
#define OPTIONS 3
#define CREDITS 4
#define QUIT 5
using namespace irr;
using namespace core;
using namespace io;
using namespace video;
using namespace gui;
using namespace std;
IrrlichtDevice *MainMenuDevice = 0;
IGUIEnvironment *MainMenu = MainMenuDevice->getGUIEnvironment();
class MainMenuEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
IGUIEnvironment *MainMenu = MainMenuDevice->getGUIEnvironment();
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
if (id == QUIT)
{
MainMenuDevice->closeDevice();
return true;
}
break;
}
}
return false;
}
};
bool LoadMainMenu(void) //loads the Main menu
{
MainMenuDevice = createDevice(EDT_OPENGL, core::dimension2d<s32>(425, 350)); //Create the device
MainMenuEventReceiver MainMenuEventReceiver;
MainMenuDevice->setEventReceiver(&MainMenuEventReceiver),
IGUIEnvironment *MainMenu = MainMenuDevice->getGUIEnvironment();
IVideoDriver *driver = MainMenuDevice->getVideoDriver(); //get the videodriver
IGUISkin* skin = MainMenu->getSkin(); //load the skin to set a font
IGUIFont* font = MainMenu->getFont("C:/myfont.xml"); //load font
if (font)
skin->setFont(font); //set font if there is a font
skin->setFont(MainMenu->getBuiltInFont(), EGDF_TOOLTIP);
MainMenu->addButton(rect<s32>(64, 256, 360, 304), 0, QUIT, L"Beenden"); //}
MainMenu->addButton(rect<s32>(64, 200, 360, 248), 0, CREDITS, L"Credits"); //}
MainMenu->addButton(rect<s32>(64, 144, 360, 192), 0, OPTIONS, L"Optionen"); //}create the buttons
MainMenu->addButton(rect<s32>(64, 88, 360, 136), 0, MULTIPLAYER, L"Mehrspieler"); //}
MainMenu->addButton(rect<s32>(64, 32, 360, 80), 0, SINGLEPLAYER, L"Einzelspieler");//}
while(MainMenuDevice->run() && driver) //draw the whole stuff
if (MainMenuDevice->isWindowActive())
{
MainMenuDevice->getVideoDriver()->beginScene(true, true, SColor(0,200,200,200));
MainMenu->drawAll();
MainMenuDevice->getVideoDriver()->endScene();
}
MainMenuDevice->drop();
return 0;
}
dann erhalte ich die Fehlermeldung:
'irr::gui::IGUIEnvironment': Ungültige Verwendung dieses Typs als Ausdruck|
||=== Build finished: 1 errors, 1 warnings ===|
wenn ich den receiver rausnehme funktioniert das programm .
Wo hab ich da einen fehler?