I'm a newbie here and in XNA programming, but I have some skills in C#. Now I am trying to make a match3 game in XNA 4.0 with Visual Studio 2010 and I got into trouble.
I have created a class, called Tile, which has information about the tile like: Texture2D, Vector2 position, some bools, ints and so on. In another class I have 2D array (8x8) of this tile objects (total of 64). When I run the game I can see the grid with the textures as they should be. I was able to create a method for selecting the tiles by mouse clicking, but I can't swap the two tiles. Here is my swap method:
public void swapPieces(int x1, int y1, int x2, int y2)
{
Tile temp;
temp = Tiles[x1, y1];
Tiles[x1, y1] = Tiles[x2, y2];
Tiles[x2, y2] = temp;
}
where x1
, y1
, x2
and y2
are the coordinates in the array of the two selected tiles and Tiles[,]
is my two dimensional array. When I trace the game, I see that the tiles are swapped, but visual I see no changes. How I can deal with this situation? Thanks.