![]() ![]() Initializing an array just means that we give each slot of the array an initial value in preparation for it to be used elsewhere in the project code. We've shown how to check an array for data, but how do we create the array to start with? First it has to be initialized before we can use it or GameMaker Studio 2 will give us an error. It's worth noting that the contents of an array always start at 0 and can never be negative ! Creating Arrays So essentially, an array is a container with a number of slots to store values, and each position in the container has a specific number to identify it, which is what we put in the. If you did the following:Īs you can see, you give the array a variable name and then a value in square brackets, where the value is the position in the array to get the data from. The above code gets the value from position 0 of the array " a" then outputs it to the console, which - based on the contents of the array shown in the image above - would output 125. ![]() To access the array you would do something like the following: ![]() This is called a 1D (one-dimensional) array, and as you can see the array is stored in the variable " a" and contains multiple values. The image below shows a schematic for a basic array: An array is simply a data type that is assigned to a variable, and it can contain not just one value, but multiple values. Before going any further let's clarify what an array actually is and how it's structured. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |