jpv123
All the for-loops are doing is telling you which tile is in which position in the TMXTilemap. Knowing where the background tiles are allows you to compare the location of the background tiles with the location of the sprite (obviously, you would multiply the row and col of the tile by the dimensions of the each tile in your tilemap).
For example, if your tiles are 32x32 pixels and you have a non-zero background tile at col=15, row=10, then that means there is a tile sprite at X=15x32=480, Y=10x32=320. So knowing that you would compare the location of your sprite and the location of tile you would create two CGRects (one for the sprite and one for the tile) and make the call:
if (CGRectIntersectsRect(sprite_rect, background_tile_rect)
{
[....sprite touched background tile ---- print label at X, Y...]
}
I use box2d for my collision detection, so this is only a very rough idea of how you would do it strictly with Cocos2d. There may very well be a better approach and if so, hopefully someone more knowledgeable will chime in.
I recommend (if you haven't already done so) that you run the Cocos2d Testbed examples (located in the Cocos2d Test directory) and try them all out. When you find an example that generally does something you want your program to do, look into the code and experiment with different values until you understand what the code is doing. There are tons of different example to look at and it really is terrific way to get familiar with Cocos2d. Additionally the examples are the best place to look at first when you have a question about something. If you don't understand the example, then ask question about it and it is alot easier for people to answer since we all have access to the same example code. Also, the Box2d and chipmunk physics engines' testbeds are also located in the Test directory under cocos2d.
Regards,
Q