Posizione carburante TinyDB

Salve a tutti,
quando premo il pulsante "Pieno", tramite i 4 clock; vado a far comparire rispettivamente i 4 sprite ogni 1000, 2000, 3000, 4000 sec. e poi disabilito i timer.
Viaggiando in macchina, di volta in volta che i rilevatori di carburante si spengono; io di conseguenza, vado a cliccare sullo sprite 4 etc. Come posso salvare la posizione degli sprite rimasti, tramite TinyDB?

I would consider setting up a list of the sprites and then using the when any ImageSprite.Touched event to determine the position. For example:

Restoring the UI based on TinyDB's position value is left as an exercise.

@ewpatton, in initialize GetValue mi da semplicemente il valore 4; nonostante io abbia cliccato sullo sprite prima di chiudere l'app :thinking:

If you're testing in the companion, it's possible that another program you previously made used the tag "position", so that might explain if you are seeing a value different than what you might expect. You can always clear the database by using "Do It" on a TinyDB1.ClearAll() method block. Be aware that this impacts any other projects you test with the companion.

@ewpatton ,
ti mando un video esplicativo, così capirai meglio ciò che voglio fare nella mia app.

In pratica, se gli indicatori del carburante sono arrivati a 2; all'uscita dall'app, dovrebbe salvare la loro posizione; per poi ritrovare gli stessi 2 indicatori all'avvio dell'app.

1 Like

This  should  work :

Blocks


Make sure to keep the visible and enabled property of the VisibleSprites to false.

P.S.

Wait, I forgot to use the TinyDB1.StoreValue() block.

Another P.S.

Okay done...

1 Like

@SHUBHAMR69 ho seguito tutte le tue istruzioni; ma non funziona.
Ti allego il file AIA
ConsumoCarburanteMIT2.aia (6.1 KB)

1 Like

Here you go :

ConsumoCarburanteMIT2.aia (6.7 KB)

Fully tested and working.

Sorry for I missed some blocks in the Screen1.Initialize in the previous post. But this one is working.

You might see that sometimes, multiple imagesprites are changed.  That happens when your fingers touch multiple image sprites at the same time by mistake.  You might want to increase the size of the sprites to avoid misclicks.

@SHUBHAMR69 se clicco su 2 sprite, al riavvio dell'app non mi appaiono solamente 2 sprite rimasti; ma ugualmente tutti e 4 sprite. :thinking:

1 Like

Wait what do you actually mean ? I can't understand. Everything was working for me properly and being saved properly too.

See this video :

Everything is working for me...

P.S.

Ignore the background noise. :sweat_smile:

@SHUBHAMR69, purtroppo a me invece non funziona; adesso ti mando un video:

1 Like

Maybe you've changed something in the .aia

First, delete that project. Then, Download this .aia, Import it, Compile it and then install and run it.

Don't make any changes to this.

ConsumoCarburanteMIT2.aia (6.7 KB)

1 Like

@SHUBHAMR69 non so cosa ho cambiato nel codice del vecchio progetto; ma adesso funziona. Grazie
Saluti
Nicola

1 Like

You're Welcome.

1 Like

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