Switching screens using a variable

Okay, this is my first App Inventor forum post. Yay!

I need to know how to initialize my app screen when my timer runs out/when all ImageSprites are in the right spot (I have placement sprites) instead of using a button to end the game. I'm trying to display a score on a different screen. I have a title screen and tried to use Screen1 Initialize in order to loop an if/then statement, but the screen wouldn't change.


Anyone know a better way to do this?? Sorry if my explanation didn't make sense -- I'm quite new to code and still don't exactly understand all the mechanics. :slight_smile:

Welcome, Show your blocks of the RESULTS screen...

You can also use this block:

ScreenName: Your RESULTS screen :sweat_smile:

Hey -- sorry to keep you waiting so long. Here's the current code for my Results screen, I'm not fully done yet. :slight_smile:

1 Like

You can't place a tinydb getvalue as a variable definition.

Define the variable to an empty text, then set it to the tinydb getValue in an event block (e.g. button click or screen initialise)

Thanks!!! That worked for the points system. Still working on that screen switch though :)))

1 Like

Okay! I found out how to switch screens when my timeLeft variable gets to 0. All I had to do was put that if/else under my Timer start. :))

Make sure to disable the timer before changing screens. Failing to do so could cause the app to crash.

1 Like

Thanks! I made sure to turn the timer off just now. :))

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