Save Scene Location (Local storage maybe?)

Hi Everyone!

I am working on an “app” I’d like to put in iOS, where I want the hype project to remember the location (and maybe a score) so when the user returns to the app, they just pick up where they left off. Without having to click a load button.

Here is what this scenario would look like, “The user opens the ‘app’ and navigates to Scene 5. They close the app and return to it 2 days later. When they open the ‘app’, Scene 5 automatically loads up and let’s them pick up where they left off.”

Is this possible? If so, how would this work?

Thanks!

2 Likes

here’s a nice library to simplify the usage of localStorage

Thank you for your quick reply!

I understand the concepts of local storage, however I’m a complete novice to javascript and html. Would you happen to know where I can find an example of something like this in a hype project?

Thanks!!

Logan

For example, i’d like to do something like this "http://forums.tumult.com/t/resume-a-scene-from-its-last-played-time/1139” but when the user opens the app.

Hello,
Have you find the answer ?

Hi @Fmedioni

Here is an example of using localStorage to store the scene.

scene-localStorage.zip (90.9 KB)

5 Likes

Many thanks, your Example helped me a lot!!!

hi @mastermindcoach , and @DBear
it isnt working on safari 12.
is there a problem on my Safari of Mac, or it s a common issue?
Thanks…

This is magic! Nice work and great demo.

1 Like

Hi Dear

In the example you provided you have a function where you clear local storage:

localStorage.clear();

Is there a way to only clear the names of the scenes recorded instead of cleaning all local storage. There may be other things stored there which I may still need.

Looking forward to your reply.

Greg

you can use
localStorage.removeItem('myKey');

turning on your preferred searchengine with query like “js localStorage” will lead to several sources describing usage, methods …

2 Likes

Hi Hans

I will definitely learn more about localStorage for sure! Just one more question. Can I list several items e.g.

localStorage.removeItem('myKey', 'myKey2', 'myKey3');

Thanks for your help.

Greg

no remove one at a time or clear all …

let keysToRemove = ["key1", "next"];

for (key of keysToRemove) {
    localStorage.removeItem(key);
}



as iteration ...
3 Likes

Hi Hans

I dug a little into local storage and came up with this. In this little project, not only the scene name but also the state of each timeline within each scene are stored in local storage and are kept the same even when you reload the page or close the browser accidentally.

Store Scene and Timeline (Local Storage).zip (88.7 KB)

Hope you like it and please feel free to improve it if you have a better ideas :slight_smile:

Thanks guys!

3 Likes

Hi Greg,

When convenient would it be possible for you to save this project in a version which is compatible for Hype 3 to open.

Would be helpful to see how you used local storage.

Thanks.

1 Like

Sure! But how would I do that? I use Hype 4 Pro. Is there an option to export as a project for earlier versions of Hype?

Thanks for the reply Greg… I thought there might be an option when exporting in Hype 4, but it doesn’t sound like it.

Alternatively if you wouldn’t mind, I think if you were to “Export as HTML 5” and upload the two files (.html file and .hyperesources folder) I would be able to create an editable file using Hypes “Restore document from export” feature.

Thanks again.

I suspect that that may have issues.
The plist file fir the restore will be markedly different.

I suspect that we have a v3 example that does similar on the site somewhere…

LocalStorage is not too complicated and you should be able to construct your own by going over this thread or some of the ithers on site

It may not work but have a try anyway.

Store Scene (Local Storage).zip (86.6 KB)

1 Like

Thanks for uploading @grzesiek.rogala … I thought it would be a work around, @MarkHunte was right though.

Will look on the forums see if there is similar on v3.

Thanks again for your help guys.