How do you remove GUI elements and Textures?
I've tried ->drop(), but this doesn't seem to do it.
I've also tried guienv->clear(). This also doesn't work.
Here are pieces of my code to see if you can find problems:
Code: Select all
// Get rid of the gui elements
guienv->clear();
guienv->getRootGUIElement()->getElementFromId(GUI_ID_BUTTON_QUIT, true)->drop();
guienv->getRootGUIElement()->getElementFromId(GUI_ID_BUTTON_NEW, true)->drop();
guienv->getRootGUIElement()->getElementFromId(GUI_ID_BUTTON_LOAD, true)->drop();
guienv->getRootGUIElement()->getElementFromId(GUI_ID_BUTTON_SETUP, true)->drop();
guienv->getRootGUIElement()->getElementFromId(GUI_ID_BUTTON_DIFFICULTY_NORMAL, true)->drop();
guienv->getRootGUIElement()->getElementFromId(GUI_ID_BUTTON_DIFFICULTY_HARD, true)->drop();
guienv->clear();
Code: Select all
// Main menu buttons
IGUIButton * buttonNew = guienv->addButton(rect<s32>(10, 200, 210, 200 + 64),0, GUI_ID_BUTTON_NEW, L"New Game", L"Starts a new Game");
IGUIButton * buttonLoad = guienv->addButton(rect<s32>(10, 300, 210, 300 + 64),0, GUI_ID_BUTTON_LOAD, L"Load Game", L"Loads a previously saved game");
IGUIButton * buttonSetup = guienv->addButton(rect<s32>(10, 400, 210, 400 + 64),0, GUI_ID_BUTTON_SETUP, L"Setup", L"Sets up options for the game");
IGUIButton * buttonQuit = guienv->addButton(rect<s32>(10, 500, 210, 500 + 64),0, GUI_ID_BUTTON_QUIT, L"Quit", L"Exits the game");
// New Game Difficulty buttons
IGUIButton * buttonDifficultyNormal = guienv->addButton(rect<s32>(10, 200, 210, 200 + 64),0, GUI_ID_BUTTON_DIFFICULTY_NORMAL, L"Normal", L"Sets the games difficulty to normal");
IGUIButton * buttonDifficultyHard = guienv->addButton(rect<s32>(10, 300, 210, 300 + 64),0, GUI_ID_BUTTON_DIFFICULTY_HARD, L"Hard", L"Sets the games difficulty to hard");
// Turn all of them invisible until we are ready to render
buttonNew->setVisible(false);
buttonLoad->setVisible(false);
buttonSetup->setVisible(false);
buttonQuit->setVisible(false);
buttonDifficultyNormal->setVisible(false);
buttonDifficultyHard->setVisible(false);
// Load up an image for the button
buttonBackground = NULL;
buttonBackground = driver->getTexture("Assets/ButtonBackground.png");
if (!buttonBackground)
{
device->getGUIEnvironment()->addMessageBox(L"Error", L"Cannot Load \'Assets/buttonBackground.png\'");
}
// Change some properties of the buttons
buttonNew->setImage(buttonBackground);
buttonLoad->setImage(buttonBackground);
buttonSetup->setImage(buttonBackground);
buttonQuit->setImage(buttonBackground);
buttonDifficultyNormal->setImage(buttonBackground);
buttonDifficultyHard->setImage(buttonBackground);