Arrays for Beginners

  • 220 favourites

Index

Attached Files

The following files have been attached to this tutorial:

.capx

animals-starter.capx

Download now 173.28 KB
.capx

animals-complete.capx

Download now 174.16 KB
.capx

highscores-example.capx

Download now 182.31 KB

Contributors

Stats

30,166 visits, 108,909 views

Tools

Saving and Loading

If you want to store the contents of an array so that you can restore it the next time you load the game then you can save it to local storage. The Array.AsJSON expression will return the array in JSON format (a text-based format) which you can then store in local storage.

[11] Add the Webstorage plugin to the layout and use it's "Set local value" action to store the array:

[12] Then you can use the array Load action to restore the saved array:

[13] The Download action let's you download the array in JSON format as a text file. This is useful when creating level editors - you can add the files to your project and load them into arrays at the start of the layout.

The animals array in JSON format:

    {"c2array":true,"size":[5,1,1],"data":[[["tiger"]],[["rabbit"]],[["mouse"]],[["lion"]],[["cow"]]]}




  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!