Hi All,
I'm still fighting with this solution to add tiles to an isometric grid.
carried over from this thread;
http://forum.sparrow-framework.org/topic/isometric-grid-based-on-as3
I have the following solution which works to my knowledge but seems I can't find a way to actually add the elements of the array to the stage.
[self addChild [terrainArray objectAtIndex:i]]
Any help would be appreciated as I'm stuck.........
//--------------------------------------
//2d iso test
//--------------------------------------
SPImage *tile_img;//our tile image
int columns = 10;//columns
int rows = 10;//rows
NSMutableArray *terrainArray = [[NSMutableArray alloc] init]; //create the top level array(which will hold arrays of sprites)
int i, j;
//-----------------------
//Columns
//-----------------------
for(i = 0; i < columns; i++)
{
NSMutableArray *items = [[NSMutableArray alloc] init]; //create the second level array that will hold the actual sprites
for(j = 0; j < rows; j++)
{
//--------------------
//create a holder sprite
//--------------------
SPSprite *mySprite;
mySprite = [SPSprite sprite];
//--------------------
//load a tile image
//--------------------
tile_img = [SPImage imageWithContentsOfFile:@"map_tile.png"];
//--------------------
//add tile to sprite
//--------------------
[mySprite addChild:tile_img];
//--------------------
//add sprite to array items
//--------------------
[items addObject:mySprite];
[tile_img release];
}
[terrainArray addObject:items];
[items release];
//SPSprite *holder = [terrainArray objectAtIndex:i];
//[self addChild:[terrainArray objectAtIndex:i]];
printf("object = %d\n",[terrainArray objectAtIndex:i]);
printf("\n");
}
}