msp301 Posted February 4, 2010 Posted February 4, 2010 I am trying to move an object from 1 location in a 2D array to another, but I seem to be referencing the object itself and making it equal to another :S This a code snippet of what I've been doing, any pointers would be appreciated ChessPiece currentLocation = objBoard.board[curX][curY]; //current coordinates of piece ChessPiece destination = objBoard.board[desX][desY]; //intended destination if((desX == curX) && (desY == (curY + 1))) { destination = currentLocation; //copy contents of current location to destination square currentLocation = null; //remove contents of the old location to complete the piece move } Thanks :) Quote
Sparda Posted February 4, 2010 Posted February 4, 2010 You aren't moving the chess piece to any where, you are taking it off the board. Quote
msp301 Posted February 4, 2010 Author Posted February 4, 2010 You aren't moving the chess piece to any where, you are taking it off the board. yeah thanks, I worked it out after posting that :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.