- Home /
Creating a 2d array with the Array class
Hi!
How do I create a 2d array that I can manipulate (change length) with the Javascript Array class? All the threads that i've found are people using the built in arrays, which have a fixed length. I can't use those (it would be impractical), because my Array will be ever expanding. In case you're wondering, it will represent a grid of blocks that make up my level.
I don't think that the costly performance of 2d arrays will be an issue, since I will only have one, and the rest of the game logic is very, very simple.
Answer by robertbu · Aug 01, 2014 at 01:22 PM
Don't use the Array class. It is slow and untyped. For your application, use one of the .NET collection classes. Most often for your situation, the generic List class is recommended. More info about collections:
http://wiki.unity3d.com/index.php?title=Which_Kind_Of_Array_Or_Collection_Should_I_Use%3F
Your answer
Follow this Question
Related Questions
Need help with 2D Arrays (problems with navigating) 1 Answer
2D Grid Question 0 Answers
What type of Array should I use? 1 Answer
Splitting into 2d array with JS 1 Answer