-1

I am looking for a way to send two scores (called Coins and Gems) for a treasure game across several screens. It is for a class.

I have tried Tiny DB but it does not wipe after each game is played and I have not found a fool proof way to make it clear itself if someone closes the game.

I have tried using a close screen with start value but it only does one value and I need to have both send to the next screen.

I have also tried creating a list with the gems and coins value as the start value but then I can not continue to add the scores on the next screen and it gives me errors.

I would include screenshots and code but at this point its very jumbled together. I have also tried to make sure that each screen closes and sends the value but this has also been not successful any help would be appreciated. I can post whatever is helpful!

  • And ive tried to be a mind reader, but that didnt work for me either... Context and code is what we need, clear proof of prior effort (in part so we can see what you tried already, so code with description is best) thats needed too. http://stackoverflow.com/help/how-to-ask – Daniel Brose Sep 30 '15 at 01:07
  • to clear `TinyDB` on start of the app, just use the `Screen1.Initialize` event together with a `TinyDB.ClearAll` block, see also the [documentation](http://ai2.appinventor.mit.edu/reference/components/storage.html#TinyDB). – Taifun Oct 09 '15 at 21:42

1 Answers1

0

What it sounds like you need is an umbrella type class.

Make a separate class, with any name, for example, myApp.

Then make Coin and Gem values in the myApp Class. Use these values to maintain across multiple activities. When you are done on a certain screen, add the values accumulated on that screen to your myApp totals, then once you get to the new "activity or fragment" screen. You initialize that screen with the values from myApp Class.

If you want the totals to be cleared upon each start up, make a boolean value variable in the myApp class as well. Something like "firstGameBool", if initial value is true, then set all variables back to their initial states, set to false after first run to keep your program from erasing values after restarting play, not entire app.

king_abu1918
  • 284
  • 2
  • 6