Skip to content
August 11, 2012 / iunkn

Storing App Local data

The Windows 8 apps can store application data using the methods exposed by Windows 8. Please refer Application Data (Metro style apps)  for background. With the R3 update to the Metro plugin the capability to add application data to local machine from within Construct 2 is implemented. This means that you can store information like level unlock state, score for level, high score detail etc,. in the local app data. Note that this information persists across different launch sessions of the app/game.

I have modeled the interfaces in this plugin to be exactly the same as the WebStorage plugin included by default in Construct 2. So if you know/have used WebStorage plugin, you already know how to use this new addition to Metro plugin. 🙂

The following are newly added:

Conditions: Local Key Exists

Actions: Set Local Value, Remove Local Value, Clear Local Storage

Expression: Local Value

<I have copied the following from WebStorage plugin manual and modified it for this plugin:>

The Metro object uses a very simple storage model: values are stored under named keys, similar to how the Dictionary object works.  For example, the value 100 could be stored for the key score with the action Set local value “score” to 100.  Similarly the value John can be stored for the key name.  Then the expression Metro.LocalValue(“score”) returns “100” (as a string) and Metro.LocalValue(“name”) returns “John”, and these values persist between launches.
Note Metro only stores strings.  If you set a key to a number like 100, when you retrieve it back it will be a string.  To convert it back, use the system expression int, e.g. int(Metro.LocalValue(“score”)).


One Comment

Leave a Comment
  1. Fredrik / Aug 15 2012 9:00 pm

    This looks really good! I will test as soon as I have win 8 rtm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s