[HELP URGENT] Persistent Counter & Cooldown Timer for Slot Machine Mini-Game Across Screens
Hi everyone, its me agian
I'm developing a virtual pet game in App Inventor 2 and I'm stuck on a state persistence issue for a slot machine mini-game. I've tried several solutions, but I can't get it to work as expected.
Mini-Game Context:
- The mini-game is on a separate screen (
Screen5
, according to my blocks) from the main game screen. - The user has 5 attempts to play the slot machine.
- Once all 5 attempts are used up, the game enters a 5-minute cooldown period. During this time, the user cannot play, and a countdown timer is displayed.
- After 5 minutes, the attempts are reset to 5, and the user can play again.
The Problem:
The attempts and cooldown logic works correctly as long as the user stays on Screen5
(the mini-game screen). However, the critical problem arises when:
- The user plays (uses some attempts or all 5).
- Clicks a "Return" button to go back to the
ScreenPrincipal
(orScreen2
). - Returns to
Screen5
(the mini-game screen).
Upon returning to Screen5
, the attempt counter resets to 5, and the countdown timer disappears or doesn't work, allowing the user to play again immediately, which is not the desired behavior. I want the attempts and cooldown time to persist even if the user switches screens or closes and reopens the application.
What I need:
I need a robust structure to:
- Persist
global Intentos
and the cooldown status (if active) across screens and app sessions. - Display an accurate countdown (MM:SS format) when the game is in cooldown.
- Have the game automatically reset to 5 attempts once the cooldown period has ended, even if the user has left and returned to the screen.
Could someone please help me restructure this logic to achieve the desired persistence and countdown, using Clock.SystemTime
as suggested? I'm quite overwhelmed with all the changes and haven't managed to get it working.
Thank you very much in advance for any help you can provide!
Snark_tumascotapasivoagresiva_1 (4).aia (798.2 KB)