cocos2d CCArray

    CCArray* arr=CCArray::create();
arr->retain();//如果不加这个东西,CCArray会被清空
arr->addObject(CCSprite::create("s_1.png"));
arr->addObject(CCSprite::create("s_2.png"));
arr->addObject(CCSprite::create("s_3.png"));
arr->addObject(CCSprite::create("s_4.png"));
arr->addObject(CCSprite::create("s_5.png"));
arr->addObject(CCSprite::create("s_6.png"));
arr->addObject(CCSprite::create("s_7.png"));
arr->addObject(CCSprite::create("s_8.png"));
CCLOG("count:%d",arr->count());
CCSprite* sprite=(CCSprite*)arr->objectAtIndex();
sprite->setPosition(ccp(size.width*0.5,size.height*0.5));
addChild(sprite);
上一篇:cocos2d-x 之 CCArray 源码分析


下一篇:cocos2d-x 之 CCArray 的遍历(3)