hello everyone
I am a beginner in irrlicht and I wanted your help to create a basic game menu in c++ with play, resume and quit buttons.
Thank you
game menu
Re: game menu
You need to get a pointer to IGUIEnvironment, which can be done after device creation: env = device->getGUIEnvironment(). Add window, Add buttons with parent to be the window. To see stuff on screen, you need make sure GUI gets drawn: env->drawAll() should be called after you draw scene (if any) and before driver->endScene(). After these steps you will be able to see the menu, but it will do nothing interesting. To handle events you need to device->setEventReceiver() with you custom event receiver.
P.S.: i suggest you to read code of examples which comes with Irrlicht Engine; they show how to use IGUIEnvironment, e.g. create and handle the GUI in Irrlicht. There is a good example 05.UserInterface that shows good chunk of how it can be done.
P.S.: i suggest you to read code of examples which comes with Irrlicht Engine; they show how to use IGUIEnvironment, e.g. create and handle the GUI in Irrlicht. There is a good example 05.UserInterface that shows good chunk of how it can be done.
-
- Competition winner
- Posts: 688
- Joined: Mon Sep 10, 2012 8:51 am
Re: game menu
Something like this:
Code: Select all
int main() {
irr::IrrlichtDevice* device = irr::createDevice( irr::video::EDT_OPENGL, irr::core::dimension2du(1200,800));
if ( !device ) return 1;
irr::gui::IGUIEnvironment* env = device->getGUIEnvironment();
irr::core::dimension2du buttonSize(200,60);
irr::core::vector2di buttonCorner(200, 200);
env->addButton("New Game", irr::core::recti(buttonCorner, buttonSize));
buttonCorner.Y += (irr::s32) buttonSize.Height + 5;
env->addButton("Quit", irr::core::recti(buttonCorner, buttonSize));
while( device->run() ) {
device->getVideoDriver()->beginScene();
env->drawAll();
device->getVideoDriver()->endScene();
}
device->drop();
return 0;
}