Problem of the enabling of buttons after switching back to the same screen

Hi, I have a problem with my coding in App Inventor. I hope that some of you may help me with my query. I've made a game which compromises of 3 levels for now. I have a level menu screen which requires players to go to the screen to choose the next level. When it is initialized, I want only the button for the first level to be enabled, while the other buttons are not. However, when I press the button to the Level screen and coming back to press the next level, I want the button for the 2nd level to be enabled for players to press and go into the level's screen. I've tried a few methods already such as calling different actions in the screens, but once the screen is initialized, the buttons will just set back to the states I've set them in the "when screen is initialized" block. I also want the players so that they can choose to play the previous levels and the next level. Can anyone help me with my problem? I will send a few snapshots of my code below:

And here is the screen for level 1:

And this is the button choosing screen:

If you don't understand what I mean, I can send you the file download if you want. Thank you very much!

Use the manager screen method to switch screens

and use the OtherScreenClosed event to enable/disable your buttons

Also let me suggest you to read tip1 here

Taifun

Hi, I'm sorry but I'm still a little confused. I've followed the tutorial but it still doesn't let me enable the button.


Thanks!

The question is, how do you close the other screen?
Any screenshot?

Also it looks like you have overseen the notes in the tutorial

Current limitations of the AI Companion app:

  1. The close screen block triggers the Initialize event instead of the OtherScreenClosed event.
  2. The close screen with value block triggers both the Initialize and OtherScreenClosed events instead of only the OtherScreenClosed event.
  3. The close application block does not work, a message 'Closing forms is not currently supported during development' will be displayed instead.

Taifun

TinyDB is the easiest way to transfer data across Screens (besided just using one Screen).

This is how I close the other screen:

To close the current screen just use the close screen block (I.e.NOT the close screen with value block)

EDIT: you might want to maintain a list of the already solved levels in TinyDB to be able to decide, which buttons should be enabled in the LevelScreen

Taifun

Thank you very much! I''ll try using the TinyDB.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.