i'll tried to fix this error in which the buttons are suppose to appear and be able to be used,but they don't and it's driving me crazy
Code: Select all
//game manager.cpp
void game_manager::displaybuttons()//the button displaying
{
irrGUIEnvironment->addButton(rect<s32>(10,210,100,280), 0, 101, L"start");
irrGUIEnvironment->addButton(rect<s32>(10,250,100,290), 0, 102, L"quit");
}
void game_manager::start()
{
this->addskymap();
this->loadweapon();
this->loadmap01();
}
void game_manager::quit()
{
this->irrDevice->closeDevice();
}
bool game_manager::OnEvent(SEvent event)
{
if (event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_ESCAPE &&
event.KeyInput.PressedDown == false)
{
this->getirrDevice()->closeDevice();
}
if(event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
if(id = 101)
{
this->start();
return true;
}
if(id = 102)
{
this->quit();
return true;
}
break;
}
}
return false;
if(event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_KEY_W &&
event.KeyInput.PressedDown == true)
{
move_foward();
}
if(event.EventType == EET_KEY_INPUT_EVENT &&
event.KeyInput.Key == KEY_SPACE &&
event.KeyInput.PressedDown == true ||
EET_MOUSE_INPUT_EVENT &&
event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
{
shoot1();
}
}
//game.cpp
#include <irrlicht.h>
#include <iostream>
#include "game_manager.h"
using namespace std;
int main()
{
game_manager g_manager;
g_manager.CreateDevice();
g_manager.getirrDevice();
g_manager.getirrGUIEnvironment();
g_manager.getirrSceneManager();
g_manager.Init();
g_manager.displaybuttons();
g_manager.irrDevice->setResizeAble(true);
while(g_manager.irrDevice->run())
{
if (g_manager.irrDevice->isWindowActive())
{
g_manager.irrVideoDriver->beginScene(true, true,video::SColor(1,100,59,157));
g_manager.irrSceneManager->drawAll();
g_manager.irrVideoDriver->endScene();
}
}
g_manager.irrDevice->drop();
return 0;
}