Exemplo n.º 1
0
void SGTaskLayer::showTaskBlank()
{
    for (int ii = 0; ii < pxData->count(); ii++) {
        CCSpriterX *resultx = (CCSpriterX *)pxData->objectAtIndex(ii);
        resultx->setVisible(true);
        resultx->play();
    }
}
Exemplo n.º 2
0
void SGTaskLayer::initView(CCArray *array)
{
    ResourceManager::sharedInstance()->bindTexture("sgrewardlayer/sgrewardlayer.plist", RES_TYPE_LAYER_UI, sg_taskLayer);
    ResourceManager::sharedInstance()->bindTexture("sgstrenglayer/sgstrenglayer.plist", RES_TYPE_LAYER_UI, sg_taskLayer, LIM_PNG_AS_PNG);
    ResourceManager::sharedInstance()->bindTexture("sgvipinfolayer/sgvipinfolayer.plist", RES_TYPE_LAYER_UI, sg_taskLayer);
    ResourceManager::sharedInstance()->bindTexture("animationFile/shanguang.plist", RES_TYPE_LAYER_UI, sg_taskLayer);
    
    SGNotificationCenter *notification = SGNotificationCenter::sharedNotificationCenter();
    notification->addObserver(MSG_REWARD_SALARYENTER,
                              this,
                              callfuncO_selector(SGTaskLayer::salaryEnterListener));
    notification->addObserver(MSG_REWARD_RECOVERENTER,
                              this,
                              callfuncO_selector(SGTaskLayer::recoverEnterListener));
    notification->addObserver(MSG_REWARD_GODENTER,
                              this,
                              callfuncO_selector(SGTaskLayer::godEnterListener));
    
  
    
    float btmhgt = SGMainManager::shareMain()->getBottomHeight();
    s = CCDirector::sharedDirector()->getWinSize();
    CCSprite *title_bg = CCSprite::createWithSpriteFrameName("title_bg.png");
    title_bg->setAnchorPoint(ccp(0.5, 1));
    title_bg->setPosition(ccpAdd(SGLayout::getPoint(kUpCenter),ccp(0, -47)));
    this->addChild(title_bg,-1);
    
    CCSprite *titlecenter = CCSprite::createWithSpriteFrameName("title_bg_2.png");
    titlecenter->setAnchorPoint(ccp(0.5, 0));
    titlecenter->setPosition(ccpAdd(title_bg->getPosition(), ccp(0,  - title_bg->getContentSize().height -10)));
    this->addChild(titlecenter,10);
    titlecenter->setScaleX(4);
    
    CCSprite *title_bg_l = CCSprite::createWithSpriteFrameName("title_bg_LR.png");
    title_bg_l->setAnchorPoint(ccp(0, 0));
    title_bg_l->setPosition(ccpAdd(title_bg->getPosition(), ccp(-s.width/2,  - title_bg->getContentSize().height -10)));
    this->addChild(title_bg_l,10);
    
    CCSprite *title_bg_r = CCSprite::createWithSpriteFrameName("title_bg_LR.png");
    title_bg_r->setFlipX(true);
    title_bg_r->setAnchorPoint(ccp(1, 0));
    title_bg_r->setPosition(ccpAdd(title_bg->getPosition(), ccp(s.width/2,  - title_bg->getContentSize().height -10)));
    this->addChild(title_bg_r,10);
    
    ResourceManager::sharedInstance()->bindTexture("sanguobigpic/barrack_bg.plist", RES_TYPE_LAYER_UI, sg_taskLayer);

    CCSprite *bg = CCSprite::createWithSpriteFrameName("barrack_bg.png");
    CCRect r = CCRectMake(0, btmhgt, bg->getContentSize().width, s.height - title_bg->getContentSize().height - btmhgt);
    //bg->setScaleY(r.size.height / s.height);
    bg->setTextureRect(r);
    bg->setScaleX(s.width/bg->getContentSize().width * 1.01);
    this->addChild(bg,-5);
    bg->setAnchorPoint(ccp(0.5, 0));
    bg->setPosition(ccpAdd(SGLayout::getPoint(kBottomCenter), ccp(0,btmhgt)));

	SGButton *mainTask = SGButton::createFromLocal("store_exchangebtnbg.png", str_RankLayer_str11, this, menu_selector(SGTaskLayer::showMainTaskLayer),CCPointZero,FONT_PANGWA,ccWHITE,22);
	mainTask->setScale(1.05);
    this->addBtn(mainTask);
    mainTask->setPosition(ccpAdd(SGLayout::getPoint(kUpLeft), ccp( mainTask->getContentSize().width*.65, -49- mainTask->getContentSize().height*.55)));

    SGButton *dayTask = SGButton::createFromLocal("store_exchangebtnbg.png", str_RankLayer_str12, this, menu_selector(SGTaskLayer::showDayTaskLayer),CCPointZero,FONT_PANGWA,ccWHITE,22);
	dayTask->setScale(1.05);
    this->addBtn(dayTask);
    dayTask->setPosition(ccpAdd(mainTask->getPosition(), ccp(mainTask->getContentSize().width*1.5, 0)));

    
    dayNotice=CCSprite::createWithSpriteFrameName("publc_notice.png");
    dayTask->addChild(dayNotice);
     dayNotice->setScale(0.7);
    dayNotice->setPosition(ccp(dayTask->getContentSize().width-dayNotice->getContentSize().width/4, dayTask->getContentSize().height-dayNotice->getContentSize().height/4));
    dayNotice->setVisible(false);
    

    
    scroll = CCScrollView::create(CCSizeMake(s.width, s.height - btmhgt*.81 - title_bg->getContentSize().height - 102));
    scroll->setDirection(kCCScrollViewDirectionVertical);
    this->addChild(scroll);
    scroll->setPosition(ccp(0, btmhgt));
    scrollViewContainer = CCLayer::create();
    
    taskMenu = SGMenu::create(CCRectMake(0, btmhgt*.68, s.width, s.height - btmhgt*.68 - title_bg->getContentSize().height -35));
    //taskMenu2 = SGMenu::create(CCRectMake(0, btmhgt*.68, s.width, s.height - btmhgt*.68 - title_bg->getContentSize().height -35));
    taskMenu->setPosition(CCPointZero);
   
    scrollViewContainer->addChild(taskMenu,3,1);
    pxData = CCArray::create();
    pxData->retain();
    
    int guideId = CCUserDefault::sharedUserDefault()->getIntegerForKey("guideId");
    
    int finish = 0;

    
    int len = array->count();
    
    
    for (int i = len-1; i>=0; i--) {
        
        SGTaskObj *taskobj = (SGTaskObj *)array->objectAtIndex(i);
        SGDayTaskDataModel *task = SGStaticDataManager::shareStatic()->getTaskById(taskobj->gettaskId());
    
        SGCCLabelTTF *name = SGCCLabelTTF::create(task->gettaskname()->getCString(), FONT_PANGWA, 36);
       // CCLOG("%s",task->gettaskname()->getCString());
        name->setAnchorPoint(ccp(0, 0.5));
        SGButton *item = SGButton::createFromLocal("item_bigbg.png", "", this, menu_selector(SGTaskLayer::confirmHandler));
       
        
        item->setTag(taskobj->gettaskId());
        item->setAnchorPoint(ccp(0, 0));
        //taskMenu->addChild(item);
        name->setPosition(ccpAdd(item->getPosition(), ccp(item->getContentSize().width*.1, item->getContentSize().height/2)));
        item->addChild(name);
        item->setPosition(ccp(s.width/2 - item->getContentSize().width/2,(item->getContentSize().height + skewing(5))*(len-1-i)));
        
        height += item->getContentSize().height + skewing(5);
        CCSprite *yb2 = CCSprite::createWithSpriteFrameName("store_yb.png");
        yb2->setPosition(ccpAdd(name->getPosition(),ccp(item->getContentSize().width*0.6,0)));
        yb2->setAnchorPoint(ccp(0.5,0.5));
        item->addChild(yb2,2,100);
        yb2->setVisible(false);
        
        
      //  CCLOG("%d",request->gold());
        
        CCString *nn=CCString::createWithFormat("%d",taskobj->getgold());//服务器数据
        std::string ss=nn->m_sString;
        const char*aa=ss.c_str();
        CCLabelTTF*labelw=CCLabelTTF::create(aa,FONT_BOXINFO,45);
        // CCSprite *yb2 = CCSprite::createWithSpriteFrameName("store_yb.png");
        labelw->setPosition(ccpAdd(name->getPosition(),ccp(item->getContentSize().width*0.6+40,0)));
        labelw->setColor(ccYELLOW);
        labelw->setVisible(false);
        item->addChild(labelw,2,102);
        
     
        CCSprite *lingstart = CCSprite::createWithSpriteFrameName("reward_lingq_hui.png");
        lingstart->setPosition(ccpAdd(name->getPosition(),ccp(item->getContentSize().width*0.8,0)));
        lingstart->setAnchorPoint(ccp(0.5,0.5));
        item->addChild(lingstart,9,106);
        lingstart->setVisible(true);
        taskMenu->addChild(item,5);
        
        CCSprite *hehe = CCSprite::createWithSpriteFrameName("reward_font_ylq.png");
        //hehe->setPosition(ccp(50,50));
        hehe->setPosition(ccpAdd(name->getPosition(),ccp(item->getContentSize().width*0.8+lingstart->getContentSize().width/2-hehe->getContentSize().width/2,0)));
        hehe->setAnchorPoint(ccp(0.5,0.5));
        hehe->setVisible(false);
        item->addChild(hehe,3,104);
        
        CCSprite *linging2 = CCSprite::createWithSpriteFrameName("reward_lingq.png");
        linging2->setPosition(ccpAdd(name->getPosition(),ccp(item->getContentSize().width*0.8,0)));
        linging2->setAnchorPoint(ccp(0.5,0.5));
        linging2->setVisible(false);
        item->addChild(linging2,2,103);
      //
        SGButton *linging=SGButton::create("reward_lingq.png","reward_lingq.png",this,menu_selector(SGTaskLayer::linghandle));
        //lingstart->setVisible(false);
        linging->setScale(1.4);
        linging->setTag(taskobj->gettaskId());
        linging->setAnchorPoint(ccp(0.5, 0.5));
        taskMenu->addChild(linging,1,taskobj->gettaskId()+99);
        linging->setPosition(ccpAdd(item->getPosition(),ccp(item->getContentSize().width*0.8+58,44)));
     // taskMenu->addChild(linging);
//        linging->setPosition(ccpAdd(item->getPosition(),ccp(item->getContentSize().width*0.8+20,23)));
        linging->setEnabled(false);
        linging->setVisible(false);
        
        
         if (taskobj->getisAward()==0)
        {
            lingstart->setVisible(true);
            linging->setVisible(false);
            linging->setEnabled(false);
            yb2->setVisible(true);
            labelw->setVisible(true);
        }
        else if (taskobj->gettaskCount() >= task->gettaskcount()) {
            CCLOG("taskobj->gettaskCount() >= task->gettaskcount()");
            finish++;
            if(taskobj->getisAward()==1)
            {
                
            
            linging->setVisible(false);
            linging->setEnabled(false);
            lingstart->setVisible(false);
            hehe->setVisible(true);
                
                
            }
           else if (taskobj->getisAward()==2)
            {
                //linging->setVisible(true);
                linging->setVisible(false);
                linging->setEnabled(true);
                lingstart->setVisible(false);
                linging2->setVisible(true);
                yb2->setVisible(true);
                labelw->setVisible(true);
                
                canGetRewardNum++;
            }
            
        }
        
        if(guideId < guide_tag_45 && i==0){ //任务闪烁
            CCSpriterX *resultx = CCSpriterX::create("animationFile/shanguang.scml", true, true);
            resultx->setAnchorPoint(ccp(0.5, 0.5));
            resultx->setPosition(ccpAdd(item->getPosition(), ccp(0, 5)));
            resultx->setanimaID(0);
            resultx->setisloop(true);
            scrollViewContainer->addChild(resultx, 10);
            resultx->setVisible(false);
            pxData->addObject(resultx);
        }
    }

    scroll->setContainer(scrollViewContainer);
    
    scrollViewContainer->setContentSize(CCSizeMake(s.width, height));
    
    scroll->setContentSize(CCSizeMake(s.width,height ));
    
    scroll->setContentOffset(ccp(0,-(height  - (s.height - btmhgt - title_bg->getContentSize().height - 75))));
    
    
    font1 = SGCCLabelTTF::create(CCString::createWithFormat(str_RankLayer_str13,finish,array->count())->getCString(), FONT_BOXINFO, FONTSIZE(15));
   this->addChild(font1);
    font1->setAnchorPoint(ccp(0, 0.5));
   font1->setPosition(ccpAdd(SGLayout::getPoint(kUpLeft), ccp(s.width*.05, -title_bg->getContentSize().height - font1->getContentSize().height-40)));
//    

    createMainTaskLayer();
    font1->setVisible(false);
    
    if (canGetRewardNum>0) {
        dayNotice->setVisible(true);
    }
}