本文整理汇总了C++中CCArray::indexOfObject方法的典型用法代码示例。如果您正苦于以下问题:C++ CCArray::indexOfObject方法的具体用法?C++ CCArray::indexOfObject怎么用?C++ CCArray::indexOfObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCArray
的用法示例。
在下文中一共展示了CCArray::indexOfObject方法的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: sizeof
bool GameLevelLayer::initWithLevel(int level) {
bool bRet = CCLayer::init();
if( bRet == true) {
this->currentLevel = level;
char levelName[10];
CCDictionary *levelsDict = CCDictionary::createWithContentsOfFile("levels.plist");
memset(levelName, 0, sizeof(levelName) );
sprintf(levelName, "level%d", level);
//当前地图关卡的背景数据//
CCDictionary *lvlDict = (CCDictionary *) levelsDict->objectForKey(levelName);
//背景音乐//
const char* bgMusic = lvlDict->valueForKey("music")->getCString();
SimpleAudioEngine::sharedEngine()->playBackgroundMusic(bgMusic, true);
SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.25f);
CCParallaxNode *pNode = CCParallaxNode::create();
CCArray *backGroundArray = (CCArray *) lvlDict->objectForKey("background");
CCObject *group1 = NULL;
CCObject *group2 = NULL;
CCARRAY_FOREACH( backGroundArray, group1) {
CCArray *nodeArray = (CCArray *)group1;
CCARRAY_FOREACH(nodeArray, group2) {
CCString* fileName = (CCString *)group2;
CCSprite *bgNodeSprite = CCSprite::create(fileName->getCString());
bgNodeSprite->setAnchorPoint( ccp(0.0f, 0.0f) );
int index = nodeArray->indexOfObject(group2);
float index2 = (float) backGroundArray->indexOfObject(group1) + 1.0f;
float ratio = ( ( 4.0f - index2) / 8.0f);
if(index2 == 4.0f)
ratio = 0.0f;
pNode->addChild(bgNodeSprite, index2 * -1, ccp(ratio, 0.6f), ccp(index * 2048, 30));
}