CCTMXTiledMap の CCTMXLayer のすべてのタイルを通過する単純なループを作成しようとしています。私が達成したいのは、すべてのタイルの位置を出力することだけですが、私の人生では、タイルをループする方法や、コンテナーにアクセスする方法さえわかりません。私は Objective-C の初心者なので、優しくしてください :)
半減してください!
私がこれまでに持っているもの:
CGSize mapSize = [_tileMap mapSize];
CCTMXLayer *backgroundLayer = [_tileMap layerNamed:@"Background"];
int h = 0;
int w = 0;
NSInteger i = 0;
for(h = 0; h < mapSize.height; h++)
{
for(w = 0; w < mapSize.width; w++)
{
i = h * mapSize.width + w;
// I tried the following but none of it worked:
//CCArray* tiles = [backgroundLayer children];
//CCSprite *tile = [backgroundLayer tileAt:tileCoord];
//CCSprite*tile = [tiles objectAtIndex:i];
//CCNode* tile = [backgroundLayer children getChildByTag:i];
CGPoint position = [tile position];
[_debugHud addTileId:i at:position];
}
}