本文整理汇总了C++中CCArray::reverseObjects方法的典型用法代码示例。如果您正苦于以下问题:C++ CCArray::reverseObjects方法的具体用法?C++ CCArray::reverseObjects怎么用?C++ CCArray::reverseObjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCArray
的用法示例。
在下文中一共展示了CCArray::reverseObjects方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getRoleAction
CCAction* ActionManager::getRoleAction(ROLE_STATE currentState,ROLE_STATE nextState)
{
CCAction * action = NULL;
CCArray* upArray = CCArray::create();
upArray->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("up_1"));
upArray->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("up_2"));
upArray->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("up_3"));
upArray->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("up_4"));
CCArray* downArray = CCArray::create();
downArray->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("down_1"));
downArray->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("down_2"));
downArray->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("down_3"));
downArray->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("down_4"));
CCAnimation *animation1 = NULL,*animation2 = NULL;
CCAnimate *animate = NULL;
switch(nextState)
{
case ROLE_SECOND_UP:case ROLE_FIRST_UP:
action = CCAnimate::create(CCAnimation::createWithSpriteFrames(upArray, 1/60.0));
break;
case ROLE_SECOND_DOWN:case ROLE_FIRST_DOWN:
upArray->reverseObjects();
action = CCSequence::create( CCAnimate::create(CCAnimation::createWithSpriteFrames(upArray, 1/60.0)),
CCAnimate::create(CCAnimation::createWithSpriteFrames(downArray, 1/60.0)),NULL);
break;
case ROLE_RUN:
if(currentState == ROLE_FIRST_DOWN || currentState == ROLE_SECOND_DOWN)
{
downArray->reverseObjects();
action = CCAnimate::create(CCAnimation::createWithSpriteFrames(downArray, 2/60.0));
}
break;
}
return action;
}
示例2: BSMakeCachedAnimation
void BSMakeCachedAnimation(const char* pNameFormat, unsigned int pStartNum, unsigned int pEndNum, float pInterval, const char* pCacheName, bool pIsLoop, bool isReverse /* = false */) {
CCArray* array = CCArray::create();
for (unsigned int i = pStartNum; i <= pEndNum; i++) {
char name[256] = {0};
sprintf(name, pNameFormat, i);
array->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name));
}
if (isReverse) {
array->reverseObjects();
}
if (pIsLoop) {
for (unsigned int i = pEndNum; i >= pStartNum; i--) {
char name[256] = {0};
sprintf(name, pNameFormat, i);
array->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name));
}
}
CCAnimation* animation = CCAnimation::createWithSpriteFrames(array, pInterval);
CCAnimationCache::sharedAnimationCache()->addAnimation(animation, pCacheName);
}
示例3: init
bool CMainSelect::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
this->setTouchEnabled(true);
// 创建背景
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCSprite* backgroud = CCSprite::create("mainsel/bg.png");
backgroud->setPosition( ccp(size.width/2, size.height/2) );
this->addChild(backgroud);
// 按钮
CCMenuItemImage *pLack = CCMenuItemImage::create("mainsel/lackNor.png",
"mainsel/lackSel.png",
this,
menu_selector(CMainSelect::lakeCallback) );
CCMenuItemImage *pForest = CCMenuItemImage::create("mainsel/forestNor.png",
"mainsel/forestSel.png",
this,
menu_selector(CMainSelect::forestCallback) );
CCMenuItemImage *pDesert = CCMenuItemImage::create("mainsel/desertNor.png",
"mainsel/desertSel.png",
this,
menu_selector(CMainSelect::desertCallback) );
CCMenuItemImage *pPrairie = CCMenuItemImage::create("mainsel/prairieNor.png",
"mainsel/prairieSel.png",
this,
menu_selector(CMainSelect::prairieCallback) );
pLack->setPosition( ccp(171, 437) );
pForest->setPosition( ccp(539, 401) );
pDesert->setPosition( ccp(864, 411) );
pPrairie->setPosition( ccp(392, 208) );
CCMenu* pMenu = CCMenu::create(pLack, pForest, pDesert, pPrairie, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
// 创建sprite sheet
CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("mainsel/jingyu.plist");
CCSpriteBatchNode *spriteSheet = CCSpriteBatchNode::create("mainsel/jingyu.png");
this->addChild(spriteSheet);
// 创建对象
CCSprite *sprite = CCSprite::createWithSpriteFrameName("jingyu01.png");
sprite->setPosition(ccp(920,220));
spriteSheet->addChild(sprite, 0);
CCArray *arrShang = CCArray::create(); // 动画帧数组
for(int i=1; i<=8; ++i)
{
CCString *name = CCString::createWithFormat("jingyu%02d.png", i);
arrShang->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name->getCString()));
}
CCArray *arrPeng = CCArray::create(); // 动画帧数组
for(int i=9; i<=11; ++i)
{
CCString *name = CCString::createWithFormat("jingyu%02d.png", i);
arrPeng->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(name->getCString()));
}
CCArray *arrPengRev = CCArray::createWithArray(arrPeng);
arrPengRev->reverseObjects();
arrPeng->addObjectsFromArray(arrPengRev);
CCFiniteTimeAction *delay = CCDelayTime::create(1);
CCAnimate* anShang = CCAnimate::create(CCAnimation::createWithSpriteFrames(arrShang, 0.25));
CCAnimate* anPeng = CCAnimate::create(CCAnimation::createWithSpriteFrames(arrPeng, 0.15));
sprite->runAction(CCRepeatForever::create((CCActionInterval*)CCSequence::create(anShang, delay, anPeng,anPeng, anPeng, anPeng, anPeng, anShang->reverse(),delay,delay,delay,NULL)));
return true;
}