problem with making gui appear

Started by Chomba, Thu 23/09/2021 08:16:51

Previous topic - Next topic

Chomba

 as I understand it, with this code the character should switch to this room, the GUI (chapter division screen) should appear, a moment pass, GUI should disappear and character switch to another room.
the function is linked to the room and everything. The GUI is set to Visible=false from its menu and popupStyle=normal.

Code: ags
// room script file

function room_AfterFadeIn()
{
 
gCapI.Visible = true;
Wait(60);
gCapI.Visible = false;
cHarrison.ChangeRoom(6);

}


But the character changes to this room, stays black for a few seconds and then goes to the other room... am I missing something in the code?

EDIT 1: Forget it, I'm using the wrong command. I should use open and not visible. I realized within minutes of posting it, I spent about an hour with this error.
EDIT 2: Nope, it didn't work

Khris

Do you see the room fading in?
Try adding a Display command, like  Display("GUI will appear");  in line 5 of that snippet. Do you see that?

Chomba

The code:

Code: ags

function room_AfterFadeIn()
{
Display("Ya cargó");
// So far so good
gCapI.Visible=true;
Display("Sigue");
// up to this point the display sign and the gui appeared at the same time.
// I Click to pass the message...
// The GUI and the message disappear (Why???)
Wait(200);
// It Waits
Display("Esperó");
// The message appear
gCapI.Visible=false;
cHarrison.ChangeRoom(6);
}


The video about it:


Crimson Wizard

Are you sure there's no code in repeatedly-execute functions that would disable gui?

What if you remove "Wait", will the GUI be kept until the next Display?

Chomba

#4
I was watching that. The Gui disappears every time the "Wait" command appears.
I tried making the Gui appear when exiting the previous room and making it wait in this one. The gui appeared for an instant and you can see that when you execute the Wait command, it disappears.

QuoteAre you sure there's no code in repeatedly-execute functions that would disable gui?

I have nothing in repeatedly-execute

QuoteWhat if you remove "Wait", will the GUI be kept until the next Display?

Yes

Crimson Wizard

Wait() makes engine to run game updates, and "repeatedly_execute_always" function (I said "repeatedly_execute", but now remember it's not getting called during Wait).

My thinking currently is that something happens during these updates, or in rep-exec-always that causes the gui to hide.

Chomba

#6
QuoteWait() makes engine to run game updates, and "repeatedly_execute_always" function (I said "repeatedly_execute", but now remember it's not getting called during Wait).

My thinking currently is that something happens during these updates, or in rep-exec-always that causes the gui to hide.

I tried moving it to other rooms to see if it was something in the configuration of this particular one, but no, the same thing always happens.

I didn't put anything in any place to repeatedly_execute_always or repeatedly_execute, the only commands like that in the code are the ones in the global script, where I haven't touched anything yet.

The weirdest thing that I put so far (that I had not used before) is the command "while (IsGamePaused()) UnPauseGame();" in the functions of some Gui buttons, could it be because of that?

Edit: nope, I tried to override those commands... but it wasn't that

Khris

That line doesn't make sense; you can replace "while" with "if". Then it still won't make sense, because you don't need to check the pause state if you're going to unpause the game no matter what.
Replace the line with just  UnPauseGame();.

Next, search your entire project for "gCapI".

Crimson Wizard

#8
Go to General Settings -> Visual -> "When player interface is disabled GUI should". Make sure that it's not "be hidden". "Wait" is considered a blocking action and makes interface disabled.



Quote from: Khris on Thu 23/09/2021 18:14:22
That line doesn't make sense; you can replace "while" with "if". Then it still won't make sense, because you don't need to check the pause state if you're going to unpause the game no matter what.
Replace the line with just  UnPauseGame();.

Khris, Pause/UnPauseGame work as increment/decrement, not as a boolean switch. You have to call UnPause for a many times as you called Pause.

Chomba

QuoteThat line doesn't make sense; you can replace "while" with "if". Then it still won't make sense, because you don't need to check the pause state if you're going to unpause the game no matter what.
Replace the line with just  UnPauseGame();.

I got it from the manual:
Quote
UnPauseGame

UnPauseGame ()

Resumes the game.

Example:

if (IsGamePaused() == 1)
    UnPauseGame();
will unpause the game if it is paused.

NOTE: Because PauseGame works as a counter, if you called it more than once, this won't work. To ignore this behavior, unpause as much as needed with the below snippet.

while (IsGamePaused()) UnPauseGame();


QuoteGo to General Settings -> Visual -> "When player interface is disabled GUI should". Make sure that it's not "be hidden". "Wait" is considered a blocking action and makes interface disabled.

I LOVE YOU!!
  :-D :-D
I can't believe it was that!!! I don't even remember changing that option...I may have scrolled over the options unintentionally?

THANKS Guys! I wasted too much time on this  8-0

Khris

Quote from: Crimson Wizard on Thu 23/09/2021 18:15:31Khris, Pause/UnPauseGame work as increment/decrement, not as a boolean switch. You have to call UnPause for a many times as you called Pause.
Right, I completely forgot about that.

SMF spam blocked by CleanTalk