In game pausing with cegui menus

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
esr
Posts: 2
Joined: Tue Jan 04, 2011 6:32 pm

In game pausing with cegui menus

Post by esr »

I've been tinkering around with a project in irrlicht and can't figure out for the life of me how to get an in game pause to work.

Code: Select all

bool pause = false;
...
while (device->run()) {
        device->getVideoDriver()->beginScene(true, true, video::SColor(255, 20, 20, 40));
        if (device->isWindowActive() && !paused) {
            DeltaTime = irrTimer->getTime() - TimeStamp;
            TimeStamp = irrTimer->getTime();
            UpdatePhysics(DeltaTime);
            device->getSceneManager()->drawAll();
        } else if (paused) {
            printf("Paused!");
        }

        CEGUI::System::getSingleton().renderGUI();
        device->getVideoDriver()->endScene();

    }
as it is, this code will pause the game but won't allow it to restart, and loses the scene (I'd like to overlay a transperancy)


However, on changing a couple lines to this:

Code: Select all

while (device->run()) {video::SColor(255, 20, 20, 40));
        if (device->isWindowActive() && !paused) {
            DeltaTime = irrTimer->getTime() - TimeStamp;
            TimeStamp = irrTimer->getTime();
            UpdatePhysics(DeltaTime);
            device->getVideoDriver()->beginScene(true, true, 
            device->getSceneManager()->drawAll();
            CEGUI::System::getSingleton().renderGUI();
            device->getVideoDriver()->endScene();
        } else if (paused) {
            printf("Paused!");
        }


    }
the game pauses, retains the screen image, but still won't restart. What am I missing?
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

Just keep the code in the while()-loop as you would do normally. If the game is paused stop the timer:
Also increments the virtual timer by calling ITimer::tick();. You can prevent this by calling ITimer::stop(); before and ITimer::start() after calling IrrlichtDevice::run().
This way everything stays in its current state since the timer doesn't tick anymore.
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
Post Reply