How do I create permanent variables

0 favourites
  • 11 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi. I'm finisihing my first project but there's something I want to implement but haven't really been able to figure out how to do it using Construct features.

    I want to publish my app to the android market. I'm trying to create a variable that the game will load every time it starts, and it's not restarted even after the game was closed, phone turned off, etc. If the player dies 20 times in one play, closes the app, starts playing again and the deadths counter loads that variable and shows that he has already died 20 times.

    I tried using webstorage but doesn't really seem to work. I'm using clay.io for leaderboards and achievements and I saw there's some kind of data storage but, I don't know how to use it, besides the user will need access to internet to be able to fetch that data.

    Hope you guys can help me, thanks!

  • Well, I know you said you already used webstorage but give it another shot. I did it and it worked out really well.

  • Ok, I messed up assingning the values at start of the app. Thanks HZGaming if it wasn't for your help I would have trashed everything about webstorage, you made me look again and find my dumb mistake.

  • No prob. Glad I could help

  • HZGaming worked on preview but not when exported to crosswalk for Android.

    Any help would be appreciated.

  • :/ What was the problem?

  • HZGaming ir worked in the preview but not on my phone exported with crosswalk for Android. I will keep trying , but it.doesn't seem to work

  • 1. WebStorage means using web based storage tools. Such as cookies. WebStorage although misnamed does not actaully use the internet. The data saved in using WebStorage is actually in the local data app cache. So it works offline.

    2. Make sure your using LocalStorage not SessionStorage when saving data between application runs. Session storage means short term. Once the app closes and memory is cleared the data is gone. Where as LocalStorage means the data is stored persistently between app runtimes.

    3. Data is stored per device. Any data stored on preview does nto carry over to the device.

    If your still having problems include my name and provide a sample capx of how your using webstorage. Then I can see how your using it. If that fails then I'm not sure. I've never had problems with persistent storage on devices. It's very low level and extremly common plugin and api that all HTML5 game developers use.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • jayderyu HZGaming, finally solved it. Thanks guys, you are awesome.

    It seems like it's all good now. I'm having a little problem with sound playing a little late, I've tried changing when the sounds should be played, preloading them, etc.

  • You should mostly thank jayderyu for the webstorage issue but the sound problem you mentioned is, in my opinion, quite common. All my games at some point have random delays in sounds and I haven't found a solution. However, many customers most likely don't play with their sound on, especially if its just for effect.

  • Just to give an FYI about sound. I've heard about audio lag from Unity developers concerning Android. This may in fact be an Android OS issue.

    I've never deeply looked into it. but here are a couple of threads.

    http://answers.unity3d.com/questions/52 ... droid.html

    http://forum.unity3d.com/threads/androi ... es.173234/

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)