Arrays for Beginners

24
  • 250 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

45,361 visits, 150,980 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

3-dimensional arrays

A 3-d array is harder to visualize (and draw...) but you might think of it like this:

Another way to look at arrays is: if a 1-d array is a list of cells then in a 2-d array you can imagine that each cell is another list of cells. In a 3-d array, each of those cells is yet another list of cells.

Example use for a 3-dimensional array

If, in our previous example, we wanted to store some more information about the blocks eg. their angles, then we could put that in the z dimension.

We set the size of the array to 4,3,2. Now blocks.At(x,y,0) will store the animation for the block and blocks.At(x,y,1) will store it’s angle.

Further reading

See the manual page for arrays.

See the Arrays section of the

How Do I? FAQ thread for some examples of how to use arrays.

.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
  • 7 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • Hi, what's going on with second and other pages of this tutorial - it shows just an error...

  • Thank you very much.

    With new version we can change WebStorage plugin to LocalStorage plugin, And use LocalStorage On item "array_save_example" event for set animals when LocalStorage Get item "array_save_example" loaded

    1. btn loadArray on clicked > LocalStorage Get item "array_save_example"

    2. LocalStorage On item "array_save_example" get > animals Load from Json string LocalStorage.ItemValue

    • Thanks for trying to provide an update to the Webstorage reference. i'm totally lost from your update however. i'll have to find a more up to date tutorial.

  • Thanks for very good and important topic with detailed explanation

  • Best writing on arrays

  • Thank u, it helps a lot. 😁😁😁😬😬😬😬