I’m brand new to scripting and coding overall. I am following a js tutorial book that is having me script for a card matching game. I’ve had plenty of errors and managed to work most of them out alone and with some help. Currently I have this new error.
Assets/Scripts/GameScript.js(23,29): BCE0005: Unknown identifier: ‘Arraylist’.
This is my code
//#pragma strict
var cols : int = 4; // the number of the columns in the card grid
var rows : int = 4; // the number of rows in the card grid
var totalCards : int = cols * rows; //
var matchesNeededToWin : int = totalCards * .5; //If there are 16, the player needs to find 8 matches to clear the board
var matchesMade : int = 0; //At the outset, the player has not made any matches
var cardW : int = 100; // Each card's width and height is 100 pixels
var cardH : int = 100;
var aCards : Array; // store all the cards created in this array
var aGrid : Array; //Array will keep track of the shuffled, dealt cards
var aCardsFlipped : ArrayList; //This array stores the two cards that the player flips over
var playerCanClick : boolean; //to determine when player can click or not
var playerHasWon : boolean = false; // store wether or not the players has won, start as false.
function Start ()
{
//sets up the play area
playerCanClick = true; // allows player to click on cards
//initialize the arrays as empty lists:
aCards = new Array ();
aGrid = new Array ();
aCardsFlipped = new Arraylist ();
for (i = 0; i < rows; i++) //creates iterative loop to place rows on grid incrementally
aGrid *= new Array (); //Create a new, empty array at index i*
for (j=0; j < cols; j++) //creates iterative loop to place cols on grid incrementally
{
aGrid [j] = new Card (); //places new cards in the play grid
}
}
function OnGUI ()
{
GUILayout.BeginArea (Rect(0,0,Screen.width,Screen.height));
BuildGrid();
GUILayer.EndArea ();
print (“building grid!”);
}
class Card extends System.Object
{
var isFaceUp : boolean = false;
var isMatched : boolean = false;
var img : String = “robot”;
}
function Card()
{
img = “robot”;
}
function BuildGrid ()
{
GUILayout.BeginVertical (); //begin building play area placing cards vertically
for (i =0; i < rows; i++) //places cards incrementally until reaching 4
{
GUILayout.BeginHorizantal (); //begin placing cards horizantally
for (j = 0; j<cols; j++) // places cards in cols horizantlly until reaching 4
{
var card : Object = aGrid*[j];*
if (GUILayout.Button(Resources.Load(card.img), GUILayout.Width(cardW)))
{
Debug.Log (card.img);
}
}
GUILayout.EndHorizontal ();
}
GUILayout.EndVertical ();
}
Any help would be greatly appreciated!