2D Array with ArrayList for map

I switched them around in my tile class like so:


private void loadLevel() {
	int[][] levelData = new int[][] {
			{0,0,0,0,1,0,0,0,0,0},
			{0,0,0,0,1,0,0,0,0,0},
			{3,3,3,3,1,3,3,3,3,3},
			{0,0,0,0,1,0,0,0,0,0},
			{0,0,0,0,1,0,0,0,0,0},
			{0,0,0,0,2,1,0,0,0,0},
			{0,0,0,0,0,1,0,0,0,0},
			{0,0,0,0,0,1,0,0,0,0},
			{0,0,0,0,0,1,0,0,0,0},
			{0,0,0,0,0,1,0,0,0,0}
	};
	
	
		
	
	for (int y = 0; y < 9; y++) {
		for (int x = 0; x < 9; x++) {
			Tile tempTile = new Tile(levelData[y][x],new Vector2(y,x));
			tileList.add(tempTile);
			
			
		}
}



}

public void Render(SpriteBatch batch) {
	
	for (int i = 0; i < tileList.size(); i++) {
		tileList.get(i).render(batch);
	}
}


But in my tile class where I actually draw them, it calls for x and y so I left them…Do I use y for everywhere x is referred and vice versa?



	public void render(SpriteBatch batch) {
		if (tileType == 0) {
			batch.draw(new TextureRegion(tileTexture, 0, 0, 16, 16), tilePos.x,
					tilePos.y);

		} else {
			if (tileType == 1) {
				batch.draw(new TextureRegion(tileTexture, 0, 16, 16, 16),
						tilePos.x, tilePos.y);

			} else {

				if (tileType == 2) {
					batch.draw(new TextureRegion(tileTexture, 16, 0, 16, 16),
							tilePos.x, tilePos.y);

				} else {

					if (tileType == 3) {
						batch.draw(new TextureRegion(tileTexture, 16, 16, 16,
								16), tilePos.x, tilePos.y);
					}
				}
			}
		}
	}

Change the [icode]new Vector2(y, x)[/icode] to [icode]new Vector2(x, y)[/icode] but leave everything else as-is.

…You’re awesome. So why does the iterator need to be reversed but not the rest? Is it the order in which it iterates?

Should I be disposing of the tempTile somehow before I start on the next iteration? I changed one of the bottom lines to another color and it’s making the whole line that tile…It doesn’t make sense. I’ve gone through the code.

The position of the tile is still the same but the location of the data has changed.

I see. I think I know what’s going on. It’s with my camera.