本文整理汇总了C++中CCArray::removeObject方法的典型用法代码示例。如果您正苦于以下问题:C++ CCArray::removeObject方法的具体用法?C++ CCArray::removeObject怎么用?C++ CCArray::removeObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCArray
的用法示例。
在下文中一共展示了CCArray::removeObject方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: checkAtkMonster
void Hero::checkAtkMonster(float ft) {
/* 获取关卡地图Layer */
TollgateScene* scene = (TollgateScene*)GlobalClient::sharedGlobalClient()->getCurTollgateScene();
TollgateMapLayer* layer = (TollgateMapLayer*)scene->getChildByTag(TAG_MAP_LAYER);
/* 获取关卡中已出场的怪物列表 */
CCArray* monsterList = layer->getMonsterList();
if(m_atkMonster != NULL) {
/* 怪物已死亡 */
if(m_atkMonster->isDead()) {
/* 从怪物列表中删除怪物 */
monsterList->removeObject(m_atkMonster);
/* 清除锁定的怪物引用 */
CC_SAFE_RELEASE_NULL(m_atkMonster);
return;
}
/* 攻击冷却结束,可以攻击 */
if(m_isAtkCoolDown == false) {
atk();
}
/* 判断怪物是否离开攻击范围 */
checkAimIsOutOfRange(monsterList);
}
else {
/* 选择一个进入攻击范围的怪物 */
chooseAim(monsterList);
}
}
示例3:
void
MCMercenaryManager::saveData()
{
CCUserDefault *userDefault = CCUserDefault::sharedUserDefault();
JsonBox::Array mercenaries;
CCObject *obj;
MCMercenary *mercenary;
char o_id_buffer[5] = {0};
char *c_str_o_id = o_id_buffer;
CCArray *hired = hired_->getRoles();
hired->removeObject(MCHero::sharedHero());
CCARRAY_FOREACH(hired, obj) {
mercenary = (MCMercenary *) obj;
mc_object_id_t o_id = mercenary->getID();
o_id_buffer[0] = o_id.class_;
o_id_buffer[1] = o_id.sub_class_;
o_id_buffer[2] = o_id.index_;
o_id_buffer[3] = o_id.sub_index_;
JsonBox::Object mercenaryObject;
mercenaryObject["id"] = JsonBox::Value(c_str_o_id);
mercenaryObject["name"] = JsonBox::Value(mercenary->getName()->getCString());
mercenaries.push_back(mercenaryObject);
}
示例4: findPathFromTo
/* Our implementation of the A* search algorithm */
CCArray* AStarPathNode::findPathFromTo(AStarNode *fromNode, AStarNode *toNode) {
CCArray *foundPath = CCArray::createWithCapacity(2);
foundPath->retain();
if(fromNode->position.x == toNode->position.x && fromNode->position.y == toNode->position.y){
return NULL;
}
CCArray *openList = CCArray::create();
CCArray *closedList = CCArray::create();
AStarPathNode *currentNode = NULL;
AStarPathNode *aNode = NULL;
AStarPathNode *startNode = AStarPathNode::createWithAStarNode(fromNode);
AStarPathNode *endNode = AStarPathNode::createWithAStarNode(toNode);
openList->addObject(startNode);
while(openList->count() > 0){
currentNode = AStarPathNode::lowestCostNodeInArray(openList);
if( currentNode->node->position.x == endNode->node->position.x &&
currentNode->node->position.y == endNode->node->position.y){
//Path Found!
aNode = currentNode;
while(aNode!=NULL&&aNode->previous != NULL){
//Mark path
foundPath->addObject(CCValue::valueWithCCPoint(ccp(aNode->node->position.x, aNode->node->position.y)));
aNode = aNode->previous;
}
foundPath->addObject(CCValue::valueWithCCPoint(ccp(aNode->node->position.x, aNode->node->position.y)));
return foundPath;
}else{
//Still searching
closedList->addObject(currentNode);
openList->removeObject(currentNode);
for(int i=0; i<currentNode->node->neighbors->count(); i++){
AStarPathNode *aNode = AStarPathNode::createWithAStarNode((AStarNode*)currentNode->node->neighbors->objectAtIndex(i));
aNode->cost = currentNode->cost+currentNode->node->costToNode(aNode->node)+aNode->node->costToNode(endNode->node);
aNode->previous = currentNode;
if(aNode->node->active && ! AStarPathNode::isPathNodeinList(aNode, openList) && !AStarPathNode::isPathNodeinList(aNode, closedList)){
openList->addObject(aNode);
}
}
}
}
//No Path Found
return NULL;
}
示例5: deleteFrame
void ActionNode::deleteFrame(ActionFrame* frame)
{
if (frame == NULL)
{
return;
}
int frameType = frame->getFrameType();
CCArray* cArray = (CCArray*)m_FrameArray->objectAtIndex(frameType);
if (cArray == NULL)
{
return;
}
cArray->removeObject(frame);
}
示例6: unregisterAllNotifications
void GameCenter::unregisterAllNotifications()
{
CCArray* keys = m_notifications.allKeys();
CCObject* key;
CCARRAY_FOREACH(keys, key) {
CCArray *listeners = (CCArray*)m_notifications.objectForKey((unsigned int)key);
if (listeners) {
CCObject* listener;
CCCallFuncO* notification;
CCARRAY_FOREACH(listeners, listener) {
notification = (CCCallFuncO*)(listener);
listeners->removeObject(notification, true);
}
}
示例7: deleteMJGlobalInfo
bool MJHelper::deleteMJGlobalInfo(int layer, cocos2d::CCNode *node)
{
std::string layerName;
layerName = layerName + ISBeCovered + getstring(layer);
GameState *gs = GameState::getInstance();
CCArray *layerArr =(CCArray*)gs->getGlobalObject(layerName.c_str());
bool isDelete = false;
if (layerArr != NULL && layerArr->containsObject(node)) {
layerArr->removeObject(node);
isDelete = true;
}
// if (layerArr->count() <= 0) {
// gs->removeGlobalObject(layerName.c_str());
// }
return isDelete;
}
示例8: destroySlectedArray
void RootEngine::destroySlectedArray(CCArray *array, makaCompleteCallback complete)
{
if (array->count() == 0) {
if (complete) {
complete();
}
return;
}
completeCallback = complete;
containerView->unscheduleAllCallbacks();
for(int i = 0 ; i< array->count() ; i ++)
{
StarModel* model = (StarModel*)array->objectAtIndex(i);
int line = model->line;
CCArray* rowArray = (CCArray*)dataSource->objectAtIndex(line);
rowArray->removeObject(model);
allNodes->removeObject(model->node);
Sprite* sp = model->node->sprite;
containerView->scheduleOnce([sp,i,this](float dt){
if (sp->isRunning()==false) {
return ;
}
Point p = sp->getPosition();
ParticleSystem* ps = CommonUtil::getParticleSystemForImageNameAndLayer(__String::create("star.png"),Color3B::ORANGE,perWidth/2);
ps->setPosition(p);
containerView->addChild(ps);
sp->removeFromParent();
if (i<=40) {
CommonUtil::playSoundWithName(__String::create("pop"),0.8,0.8+i/16.0>1.5?1.5:0.8+i/16.0);
}
Point f = Point(p.x,p.y+perHeight);
Point t = Point(containerView->getContentSize().width/2,containerView->getContentSize().height - 100);
CommonUtil::createLabelMoveTo(f, t, __String::createWithFormat("%d",i*10+10),containerView);
}, .1*i > 4 ? 4 :.1*i, __String::createWithFormat("random%d",i)->getCString());
}
containerView->scheduleOnce([array,this](float dt){
CCArray* emptyArray = CCArray::create();
for (int i = 0; i<dataSource->count(); i++) {
CCArray* arr = (CCArray*)dataSource->objectAtIndex(i);
if (arr->count() == 0) {
emptyArray->addObject(arr);
}
}
dataSource->removeObjectsInArray(emptyArray);
for (int i = 0; i<dataSource->count(); i++) {
for (int j = 0; j<((CCArray*)dataSource->objectAtIndex(i))->count(); j++) {
StarModel* model = (StarModel*)((CCArray*)dataSource->objectAtIndex(i))->objectAtIndex(j);
model->line = i;
model->row = j;
StarNode* node = model->node;
Point p = node->sprite->getPosition();
Point t = ccp((i+ 0.5)*this->perHeight, (j+0.5)*this->perWidth);
if (p.x != t.x || p.y != t.y) {
CCActionInterval * moveBy = CCMoveBy::create(0.3,Vec2(t.x-p.x, t.y-p.y));
CCActionInterval * actionmoveback= moveBy;
node->sprite->runAction(actionmoveback);
}
}
}
containerView->scheduleOnce([this](float dt){
if (completeCallback) {
completeCallback();
}else{
if (checkDeath()) {
death();
}
}
}, 0.4, "delayClear");
}, .1*array->count() > 4 ? 4 :array->count()*.1, "relayout");
}
示例9: FindPath
bool NavigationHandle::FindPath(TilePoint start, TilePoint end)
{
bool bFindPath = false;
CCArray* openList = CCArray::create();
CCArray* closedList = CCArray::create();
ClearGraphPathInfo();
PathNode* startNode = GetNode(start);
PathNode* endNode = GetNode(end);
openList->addObject(startNode);
while(openList->count() != 0)
{
PathNode* keyNode = dynamic_cast<PathNode*>(openList->objectAtIndex(0));
closedList->addObject(keyNode);
openList->removeObject(keyNode);
if(closedList->containsObject(endNode))
{
bFindPath = true;
break;
}
CCArray* adjacentList = GetAdjacentNode(keyNode);
for(unsigned int i = 0; i < adjacentList->count(); i++)
{
PathNode* node = dynamic_cast<PathNode*>(adjacentList->objectAtIndex(i));
if(closedList->containsObject(node))
{
continue;
}
else if( !openList->containsObject(node) )
{
node->parent = keyNode;
node->hScore = CalHScore(node->position, endNode->position);
node->gScore = CalGScore(keyNode, 1);
openList = InsertOpenList(openList, node);
}
else
{
if(node->gScore > CalGScore(keyNode,1))
{
node->parent = keyNode;
node->gScore = CalGScore(keyNode,1);
openList->removeObject(node);
openList = InsertOpenList(openList, node);
}
}
}
}
if(bFindPath)
{
PathNode* kNode = dynamic_cast<PathNode*>(closedList->objectAtIndex(closedList->count() - 1));
while(kNode->parent != NULL)
{
Path->insertObject(kNode, 0);
kNode = kNode->parent;
}
return true;
}
return false;
}
示例10: rebuildLinkAt
/**
重构消除链
*/
void Troop::rebuildLinkAt(Pet* pet) {
int index = pet->getIndex();
CCString* type = pet->getType();
pet->unlock();
Pet* prev = getPetAtIndex(index - col);
int v = index;
//纵向比较前一个对象,满足:1. 不为空,2. 非锁定,3. 类型相同
if (prev != NULL && !prev->isLocked() && prev->getType()->isEqual(type)) {
v = prev->getVLink();
}
int org = pet->getVLink();
//将当前对象从原vlink中移除
if (org >= 0 && org != v && org < vlinks->count()) {
CCArray* link = (CCArray*)vlinks->objectAtIndex(org);
if (link != NULL) link->removeObject(pet);
}
//将当前对象加入到新的vlink中
((CCArray*)vlinks->objectAtIndex(v))->addObject(pet);
pet->setVLink(v);
Pet* next = (index + col < cap)? getPetAtIndex(index + col) : NULL;
//纵向比较如果有后一对象,且后一对象和当前对象有相同类型,则将属于后一对象所在vlink的对象全部移至
//当前对象所属vlink
if (next != NULL) {
int norig = next->getVLink();
if (!next->isLocked()
&& next->getType()->isEqual(type) && norig >= 0 && norig != v
&& next->getIndex() >= 0) {
CCArray* nlink = (CCArray*)vlinks->objectAtIndex(norig);
CCArray* link = (CCArray*)vlinks->objectAtIndex(v);
for (int i = 0; i < nlink->count(); i++) {
Pet* p = (Pet*)nlink->objectAtIndex(i);
link->addObject(p);
p->setVLink(v);
}
nlink->removeAllObjects();
}
}
prev = getPetAtIndex(index - 1);
v = index;
//横向比较前一个对象,满足:1. 不为空,2. 非锁定,3. 类型相同,4. 和当前对象在同一行
if (prev != NULL && !prev->isLocked() && index / col == prev->getIndex() / col && prev->getType()->isEqual(type)) {
v = prev->getHLink();
}
org = pet->getHLink();
//将当前对象从原hlink中移除
if (org >= 0 && org != v && org < hlinks->count()) {
CCArray* link = (CCArray*)hlinks->objectAtIndex(org);
if (link != NULL) link->removeObject(pet);
}
//将当前对象加入到新的hlink中
((CCArray*)hlinks->objectAtIndex(v))->addObject(pet);
pet->setHLink(v);
next = (index + 1 < cap && index % col != col - 1)? getPetAtIndex(index + 1) : NULL;
//横向比较如果有后一对象,且后一对象和当前对象有相同类型,则将属于后一对象所在hlink的对象全部移至
//当前对象所属hlink
if (next != NULL) {
int norig = next->getHLink();
if (norig >= 0 && !next->isLocked()
&& next->getType()->isEqual(type) && next->getIndex() >= 0) {
CCArray* nlink = (CCArray*)hlinks->objectAtIndex(norig);
CCArray* link = (CCArray*)hlinks->objectAtIndex(v);
for (int i = 0; i < nlink->count(); i++) {
Pet* p = (Pet*)nlink->objectAtIndex(i);
link->addObject(p);
p->setHLink(v);
}
nlink->removeAllObjects();
}
}
//如果横向或纵向的link长度大于2,将其加入remove队列
CCArray* vlink = (CCArray*)vlinks->objectAtIndex(pet->getVLink());
CCArray* hlink = (CCArray*)hlinks->objectAtIndex(pet->getHLink());
int power = 1;
if (vlink->count() > 2) {
for (int i = 0; i < vlink->count(); i++) {
removeQueue->addObject(vlink->objectAtIndex(i));
}
power += vlink->count() - 1;
}
if (hlink->count() > 2) {
for (int i = 0; i < hlink->count(); i++) {
removeQueue->addObject(hlink->objectAtIndex(i));
}
power += hlink->count() - 1;
//.........这里部分代码省略.........