本文整理汇总了C++中CCArray::removeLastObject方法的典型用法代码示例。如果您正苦于以下问题:C++ CCArray::removeLastObject方法的具体用法?C++ CCArray::removeLastObject怎么用?C++ CCArray::removeLastObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCArray
的用法示例。
在下文中一共展示了CCArray::removeLastObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kickOut
void Troop::kickOut(Pet* pet) {
int index = pet->getIndex();
if (index >= cap) return;
CCArray* vlink = (CCArray*)vlinks->objectAtIndex(pet->getVLink());
int v = vlink->indexOfObject(pet);
vlink->removeObject(pet);
while (vlink->count() > v) {
Pet* p = (Pet*)vlink->lastObject();
p->setVLink(index + col);
vlink->removeLastObject();
((CCArray*)vlinks->objectAtIndex(index + col))->insertObject(p, 0);
}
CCArray* hlink = (CCArray*)hlinks->objectAtIndex(pet->getHLink());
int h = hlink->indexOfObject(pet);
hlink->removeObject(pet);
while (hlink->count() > h) {
Pet* p = (Pet*)hlink->lastObject();
p->setHLink(index + 1);
hlink->removeLastObject();
((CCArray*)hlinks->objectAtIndex(index + 1))->insertObject(p, 0);
}
pets->replaceObjectAtIndex(index, Pet::createFakePet());
}
示例2: testPoolEfficiency
static void testPoolEfficiency(){
const int test_time = 1;
vector<int> ops;
int tot=0;
for(int i=0;i<test_time;i++){
int op=0;
if(tot){
if(rand()%2==0){
op=1;
}
}
if(op) tot--;
else tot++;
ops.push_back(op);
}
{
LifeCircleLogger logger("use system new");
CCArray *tmp = CCArray::array();
for(int i=0;i<test_time;i++){
if(ops[i]){
tmp->removeLastObject();
}else{
CCSprite *sp = CCSprite::node();
tmp->addObject(sp);
}
}
}{
LifeCircleLogger logger("use MTPool");
CCArray *tmp = CCArray::array();
for(int i=0;i<test_time;i++){
if(ops[i]){
tmp->removeLastObject();
}else{
CCSprite *sp = MTPoolManager::sharedManager()->getObject(sp);
tmp->addObject(sp);
}
}
}{
LifeCircleLogger logger("use boost Pool");
CCArray *tmp = CCArray::array();
for(int i=0;i<test_time;i++){
if(ops[i]){
tmp->removeLastObject();
}else{
CCSprite *sp =spritePool.construct();
tmp->addObject(sp);
}
}
}
}