2d array only acting like a flat array

Discussion in 'iOS Programming' started by jaybee2002, May 25, 2011.

  1. jaybee2002, May 25, 2011
    Last edited by a moderator: May 25, 2011

    macrumors newbie

    Joined:
    May 25, 2011
    #1
    ok here is m¥ problem,
    i have a game which is using a 2d array to load up what the user has done previously (saving state) for each level, to do this i am using a 2d array.
    at the moment i have 5 levels and 36 values so save for each level so im using-
    gameState[5][36];

    and when on the level im loading using,

    Code:
    for (i=1; i<=36; i++)
    {
    squarepic[i] = gameState[level][i];
    }
    and the oposite way round to save the game stat for the level.

    my problem arrises when i try and change between levels and the array seems to treat each level like they are the same so whatever has happened in level 1 moves over to level 2 and level 3 as if they were all the same level.

    anyone any idea why this could be happening.

    thanks jon
     
  2. macrumors 6502a

    Joined:
    Apr 1, 2007
  3. macrumors 6502

    seepel

    Joined:
    Dec 22, 2009
    #3
    Sounds like a simple logic error, where maybe you level variable isn't getting set correctly, so you end up accessing the same level rather than different ones? (P.S. 2D arrays are actually flat arrays... in memory at least. When I read the title I just had to mention it.)
     

Share This Page