How do i end a game and moove back to the first screen

Hello friends,
I'm trying to make some game and I want after 5 rounds a message will appear saying the game is over with a button that takes me back to the first screen in the app, I can't figure out how to hide the unrelated mid-game message.
Can anyone help me?

You did not show us your arithmetic procedure.

Your Submit button's if/then test for an answer match is reversed. You give a consolation message if the answer matches your answer variable, and a congratulations with an extra score point if it doesn't match?

You have a typo in your end_game procedure name. Retype the name and the calls to it will be corrected automatically.

Reopening Screen1 is not the way to reset your program variables. Instead, code a procedure (call it, let's say, reset) and call it from Screen1.Initialize and from the places where you wanted to start a new game. In that procedure, set score to 0, and number of games to 0. You probably have some other variables to reset in that procedure.

See the notes on why you should not open Screen1 in the Screens FAQ:

P.S. Give my regards to Nissan and Tammuz.

1 Like

hi,
Thank you, you were right about the Submit button,
so i changed the initializing to the same screen of the game so they can choose the "New Game" option and start over But it still gives me the two messages at the end of the game instead of just the message of the end of the game, how can this be changed so that the message of the game itself does not appear at the end,
Second thing, I do not find a way I can streamline the procedure, I want every random round of numbers to show me a number of images identical to the random number, can you help me with that?
Thank you


Oh and of course I gave Nissan and Tammuz your love :wink:

Closing this screen instead of opening Screen1 should allow the init globals to execute the next time you open this screen.

That might eliminate the duplicate message you say you got.

Your arithmetic procedure could be reduced in size by 90%, using

  • a procedure set_visibility of a list of Images
  • and two global lists of Image components,
    • Images2to6 (Image2,Image3,Image4,Image5,Image6) (use the green component blocks)
    • Images7to11 (Image7,...,Image11)
procedure set_visibility(images, num)
  for i = 1 to length of list(images)
    set (select item i from images).Visible to (i <= num)
  end
end

Replace all that image visibility code in the arithmetic procedure with 2 calls:

  • call set_visibility(Images2to6, num1)
  • call set_visibility(Images7to11, num2)

You will need to use

  • component blocks (found at the end of the list of blocks for each component) and
  • generic (any Image) blocks.
1 Like

Thank you, i will try to do the procedure this way.
And as for the duplication of messages, it did not work, this button you said to delete is a button that gives the user the option to return to the home page at any stage he wants, do you have maybe another idea?

I did not want you to delete the entire button.

I asked that you replace the open Screen1 block with a close screen block.

Try that first.

1 Like

Thank you for all your help.
i did not understand how to make the loop with the blocks. i do not see how i have the option to work with it like in Python,can you shoe me an example how to do this?
Thank you

Use this block, found in the Control section:
image

i did that but how do i continue?

image

Thank you!
Do you know how i can do this according to the random numbers i want the app to choose?

Please read chapters 19 and 20 of
http://www.appinventor.org/book2
from

1 Like