Pausing the GUI

(First of all, I don’t mind if you guys work in Nifty or in just the standard guiNode, but I certainly find the latter much easier and handier to use for my purpose, which is not at all very advanced.)

So, I wanted to pause the gui for a second or two, or at least a certain subnode of it, and then be able to “resume” it again. Now, this sounds a bit weird, but maybe in pseudocode it sounds better:

[java]
guiNode.attachChild(ImageToDisplay1);
guiNode.pause(1000); //Shows the first image for 1 second
guiNode.resume();
guiNode.detachChild(ImageToDisplay1);
guiNode.attachChild(ImageToDisplay2);
guiNode.pause(2000); //Shows the second image for 2 seconds
guiNode.resume(); //Allows the guiNode to be manipulated again.
[/java]

Now, maybe if this could be in some way manipulated using a trick similar to the one with a red loading bar for Nifty gui (I recall reading it somewhere, can’t seem to locate it anymore), that would of course work great… Basically what I need it for is a series of images (an animation-ish, but much longer. I am not very knowledged about animations for 2D) which I want to replace after a certain amount of time.

Thanks :slight_smile:

So, it sounds like you aren’t really “pausing” and that thinking is going to trip you up. You are just switching images after some period of time. The simplest way to do this would be to switch the images after some period of time has passed.

In semi-pseudo code:
[java]
Spatial[] images = { ImageToDisplay1, ImageToDisplay2, … }
float[] times = { 1, 2, … }
int currentImageIndex = 0;
float nextImageTime = 0;

on update…
nextImageTime += tpf;
if( nextImageTime > times[currentImageIndex] ) {
// switch the images
images[currentImageIndex].removeFromParent();
currentImageIndex++;
nextImageTime = 0;
guiNode.attachChild(images[currentImageIndex]);
}
[/java]

…with bounds checking, etc., etc.

1 Like