当前位置: 首页>>代码示例>>C++>>正文


C++ CCLayerColor::visit方法代码示例

本文整理汇总了C++中CCLayerColor::visit方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayerColor::visit方法的具体用法?C++ CCLayerColor::visit怎么用?C++ CCLayerColor::visit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCLayerColor的用法示例。


在下文中一共展示了CCLayerColor::visit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadResAndInit

void AdventureLevelClass::loadResAndInit()
{
    CCSize size = LcdAdapClass::sharedLCDADAP()->getWinSize();
    
    
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Themes/scene/stages_bg-hd.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Themes/scene/themescene1-hd.plist");
    
    memset(comBuffer, 0, sizeof(comBuffer));
    sprintf(comBuffer, "Themes/scene/stages_theme%d-hd.plist",GameStageConClass::sharedStageCon()->getGameStageIndex());
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(comBuffer);
    
    
    bgSprite = CCSprite::createWithSpriteFrameName("ss_bg.png");
    CCSize bgSize = bgSprite->getContentSize();
    //    bgSprite->setPosition(ccp(size.width / 2, size.height / 2));
    LcdAdapClass::sharedLCDADAP()->setAdaptorNodePos(bgSprite, ccp(size.width / 2, size.height / 2));
    this->addChild(bgSprite,1);
    
    CCSprite* bgCN = CCSprite::createWithSpriteFrameName("ss_bg_CN.png");
    bgCN->setPosition(ccp(bgSize.width/2, bgSize.height/2));
    bgSprite->addChild(bgCN,1);
    
    
    if (GameStageConClass::sharedStageCon()->getGameStageIndex() != GAME_STAGE_TYPE_EXTRE) {
        memset(comBuffer, 0, sizeof(comBuffer));
        sprintf(comBuffer, "ss_towers_%02d.png",(curPageIndex + 1));
        levelTowerTypeSP = CCSprite::createWithSpriteFrameName(comBuffer);//default
        levelTowerTypeSP->setPosition(ccp(bgSize.width/2, bgSize.height * 18/100));
        bgSprite->addChild(levelTowerTypeSP,3);
        
        levelNumSP = CCSprite::createWithSpriteFrameName("ss_waves_10.png");//default
        levelNumSP->setPosition(ccp(bgSize.width/2, bgSize.height * 84/100));
        bgSprite->addChild(levelNumSP,3);
        
        CCSprite* leftCloud = CCSprite::createWithSpriteFrameName("ss_cloud.png");
        CCSize cloudSize = leftCloud->getContentSize();
        leftCloud->setPosition(ccp(bgSize.width / 2, bgSize.height / 2));
        bgSprite->addChild(leftCloud,5);
    }
    
    ccColor4B color;
    color.a = 125;
    color.b = 0;
    color.g = 0;
    color.r = 0;
    
    scrollLayer = CCLayer::create();//default pos is (0,0)
    scrollLayer->setContentSize(CCSize(size.width * levelNum / 2, size.height));
    bgSprite->addChild(scrollLayer,15);
    
    
    
    for (int i = 0; i < levelNum; i++) {
        
        gameLevelInfoStruct levelInfo = HUDClass::sharedHUD()->getGameCurLevelInfo((GAME_STAGE_TYPE)(GameStageConClass::sharedStageCon()->getGameStageIndex()), (i + 1));
        
        
        
        memset(comBuffer, 0, sizeof(comBuffer));
        sprintf(comBuffer, "ss_map%02d.png",(i + 1));
        CCSprite* sprite = CCSprite::createWithSpriteFrameName(comBuffer);
        CCSize spriteSize = sprite->getContentSize();
        //sprite->setPosition(ccp(size.width / 2, size.height / 2));
        
        memset(comBuffer, 0, sizeof(comBuffer));
        sprintf(comBuffer, "%s","gainhonor_1.png");//这里要加个判断,判断用户的荣誉
        CCSprite* honorSP = NULL;
        if (levelInfo.UserGained > 0 && levelInfo.UserGained < 4) {
            sprintf(comBuffer, "gainhonor_%d.png",levelInfo.UserGained);
            honorSP = CCSprite::createWithSpriteFrameName(comBuffer);
            honorSP->setVisible(true);//要不要显示
        }
        else
        {
            honorSP = CCSprite::createWithSpriteFrameName(comBuffer);
            honorSP->setVisible(false);//要不要显示
        }
        
        honorSP->setPosition(ccp(spriteSize.width * 84/100, spriteSize.height * 22/100));
        sprite->addChild(honorSP,1);
        
        CCSprite* allClearSP = CCSprite::createWithSpriteFrameName("gainhonor_4.png");
        if (!levelInfo.isClearAllObject) {
            allClearSP->setVisible(false);
        }
        allClearSP->setPosition(ccp(spriteSize.width * 60/100, spriteSize.height * 22/100));
        sprite->addChild(allClearSP,1);
        
        levelNormalArray->addObject(sprite);//normal
        
        CCLayerColor* layer = CCLayerColor::create(color);
        layer->setContentSize(spriteSize);
		ccBlendFunc blend = {GL_DST_ALPHA, GL_SRC_ALPHA};
		layer->setBlendFunc(blend);
        
        CCRenderTexture* rt = CCRenderTexture::create(spriteSize.width, spriteSize.height);
        sprite->setPosition(ccp(spriteSize.width/2, spriteSize.height/2));
        rt->begin();
        sprite->visit();
//.........这里部分代码省略.........
开发者ID:ajaning,项目名称:TowerDefence,代码行数:101,代码来源:AdventureLevelClass.cpp


注:本文中的CCLayerColor::visit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。