void CTaskMode::createSpr(int taskId,Coordinate pos,int offiset) { if(taskId < TASK_SPECIAL_SEGMENT) { Sprite * sprAction = Sprite::create("cell2.png",Rect((taskId%IMG_X_CNT)*CELL_WIDTH,(taskId/IMG_X_CNT)*CELL_HEIGHT,CELL_WIDTH,CELL_HEIGHT)); sprArr.push_back(sprAction); sprAction->setPosition(Point(pos.m_nX*60,pos.m_nY*60+30)); addChild(sprAction); sprAction->runAction(ScaleTo::create(0.7,0.2,0.2)); sprAction->runAction(Sequence::create(MoveTo::create(0.8,allLocation[offiset]), CallFuncN::create(this,callfuncN_selector(CTaskMode::removeAction)),nullptr)); } } void CTaskMode::removeAction(Node *node) { updateUI(1); int i; Sprite *spr = (Sprite *)node; for(i=0;i<sprArr.size();i++) { if(spr == sprArr[i]) { sprArr[i]->removeFromParent(); break; } } sprArr.erase(sprArr.begin()+i,sprArr.begin()+i+1); }
删第二个元素 vector<int> v; v.erase(v.begin()+1,v.begin()+2); 注意erase(m,n)删除第m到第n个元素,第n个不会被删除
CCCallFunc::create(this, callfunc_selector(testCallFunc::callback1)),
CCCallFuncN::create(this, callfuncN_selector(testCallFunc::callback2))
CCCallFuncND::create(this, callfuncND_selector(testCallFunc::callback3), (void*)0xbebabeba)
对应的方法
void testCallFunc::callback1(){} void testCallFunc::callback2(CCNode* pSender){} void testCallFunc::callback3(CCNode* pTarget, void* data){}
时间: 2024-10-22 16:21:53