Cela devrait fonctionner pour vous ...
// this array will hold arrays :)
cocos2d::CCMutableArray< cocos2d::CCMutableArray< cocos2d::CCObject* >* > *pseudoDoubleDimArray;
void addElements()
{
// create an array called, say.., aRow
cocos2d::CCMutableArray< cocos2d::CCObject* > *aRow = cocos2d::CCMutableArray< cocos2d::CCObject* >::arrayWithObjects(NULL);
// add elements to the array, aRow
for(int j=0;j<5;j++)
{
// let's say the object is a ccsprite...
cocos2d::CCSprite* sprite1 = cocos2d::CCSprite::spriteWithFile("yourImage.png");
sprite1->setTag(j+100);
aRow->addObject(sprite1);
}
// now create the other array that will hold the array just created...you could add more rows :)
pseudoDoubleDimArray = cocos2d::CCMutableArray< cocos2d::CCMutableArray< cocos2d::CCObject* >* >::arrayWithObjects(aRow, NULL);
}
void accessElements()
{
for(int i=0;i<pseudoDoubleDimArray->count();i++)
{
printf("\n For row: %d", i+1);
cocos2d::CCMutableArray< cocos2d::CCObject* > *row = (cocos2d::CCMutableArray< cocos2d::CCObject* >*)pseudoDoubleDimArray->getObjectAtIndex(i);
for(int j=0;j<row->count();j++)
{
cocos2d::CCSprite* sprite1 = (cocos2d::CCSprite*)row->getObjectAtIndex(j);
printf("\n Sprite %d tag: %d",j+1, sprite1->getTag());
}
}
}
je l'ai déjà mis en œuvre, mais c'est se révéler fastidieux travail tout en comparant deux objets dans la même gamme ... – Ankush