Beispiel #1
0
void MapMenu::addMenu()
{
    if (spriteBackButton != NULL) {
        spriteBackButton->removeFromParentAndCleanup(false);
    }
    spriteBackButton = CCSprite::create("Background_Estacionamento_botoes.png");
    spriteBackButton->setAnchorPoint(ccp(0, 0));
	CCSize winsize = CCDirector::sharedDirector()->getWinSize();
    
    if (winsize.height > 480) {
        spriteBackButton->setPosition(ccp(0, 430));
    }
    else
    {
        spriteBackButton->setPosition(ccp(0, 350));
    }
    
    layer->addChild(spriteBackButton, 100) ;
    
    
    
    CCMenuItem *pOpenMapItem;
    CCMenuItem *pOpen3DItem;
    if(type == MAP_NORMAL )
    {
        pOpenMapItem = CCMenuItemImage::create("button_comochegar_pressed.png","button_comochegar_pressed.png",this,menu_selector(MapMenu::openMap));
        pOpen3DItem = CCMenuItemImage::create("button_3d_on.png","button_3d_on.png",this,menu_selector(MapMenu::open3D));
        
    }
    else
    {
        pOpenMapItem = CCMenuItemImage::create("button_comochegar_on.png","button_comochegar_on.png",this,menu_selector(MapMenu::openMap));
        pOpen3DItem = CCMenuItemImage::create("button_3d_pressed.png","button_3d_pressed.png",this,menu_selector(MapMenu::open3D));
        
    }
    
      pOpenMapItem->setAnchorPoint(ccp(0, 0));
	pOpenMapItem->setPosition(ccp(0, 0));
    pOpen3DItem->setAnchorPoint(ccp(0, 0));
	pOpen3DItem->setPosition(ccp(110, 00));
    
    //  pCloseItem->setFontSize(35);
    // pCloseItem->setFontName("Helvetica");
    if (menu != NULL) {
    menu->removeFromParentAndCleanup(false);
    }
    menu = CCMenu::create(pOpenMapItem,pOpen3DItem,NULL);
    menu->setAnchorPoint(ccp(0, 0));
    
    if (winsize.height > 480) {
       menu->setPosition(ccp(50, 450));
    }
    else
    {
        menu->setPosition(ccp(50, 360));
    }

	
	layer->addChild(menu,101);
}
void FriendInvitationLayer::showInvitationCode(const char *invitationCode) {
    CCSprite *spInvitationBg = CCSprite::spriteWithFile("invitation_bg.png");
    spInvitationBg->setPosition(CCPointMake(320, 440));
    addChild(spInvitationBg);
    
    CCSprite *tempSprite1 = CCSprite::spriteWithSpriteFrameName("shareWeibo.png");
    CCSprite *tempSprite2 = CCSprite::spriteWithSpriteFrameName("shareWeibo.png");
    CCMenuItem *menuItemSina = CCMenuItemImage::itemFromNormalSprite(tempSprite1, 
                                                                     tempSprite2,
                                                                     this, 
                                                                     menu_selector(FriendInvitationLayer::inviteFriendFromWeibo));
    menuItemSina->setAnchorPoint(CCPointMake(0, 0));
    CCMenu *menu = CCMenu::menuWithItem(menuItemSina);
    menu->setPosition(CCPointMake(280, 505));
    addChild(menu);
    
    if(CGameData::Inst()->getLoginType() == enLoginReqType_TencentLogin){
        menuItemSina ->setIsVisible(CGameData::Inst()->getCommonInfo()->qq_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg);
        
    }else if(CGameData::Inst()->getLoginType() ==  enLoginReqType_SinaLogin){
        menuItemSina->setIsVisible(CGameData::Inst()->getCommonInfo()->sina_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg);
        
    }else {
        menuItemSina->setIsVisible(CGameData::Inst()->getCommonInfo()->sina_voice_fg|CGameData::Inst()->getCommonInfo()->qq_voice_fg |CGameData::Inst()->getCommonInfo()->weixin_voice_fg);
    }
    
    
    
    TextNode *lbInvitationCode = TextNode::textWithString(invitationCode, CCSizeMake(500, 40), CCTextAlignmentLeft, 32);
    lbInvitationCode->setColor(ccRED);
    lbInvitationCode->setPosition(CCPointMake(550, 646));
    addChild(lbInvitationCode);
}
Beispiel #3
0
void ADAds::fillBanner(Banner* banner)
{
#if defined(_DEBUG) && CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
    CCRenderTexture* texture = CCRenderTexture::create(100, 100);
    texture->beginWithClear(0.5f, 0.5f, 0.5f, 1);

    texture->end();

    CCSprite* s = CCSprite::createWithTexture(texture->getSprite()->getTexture());

    s->setScaleX(banner->getContentSize().width/s->getContentSize().width);
    s->setScaleY(banner->getContentSize().height/s->getContentSize().width);
    banner->addChild(s);
    s->setAnchorPoint(ccp(0,0));
    s->setPosition(ccp(0,0));
#endif

    if(_home_banners.size())
    {
        //std::random_shuffle(_home_banners.begin(), _home_banners.end());
        CustomBanner* home_ads = getCustomBanner();

        CCMenuItem* item = CCMenuItem::create(
                               home_ads, menu_selector(CustomBanner::onClick));


        CCMenu* menu = CCMenu::create();
        menu->addChild(item);

        banner->addChild(menu, 0, HOME_ADS_NODE_TAG);
        menu->setAnchorPoint(ccp(0,0));

        menu->setPosition(ccp(0,0));

        CCNode* banner_content = home_ads->getBanner();
        CCSize content_size = banner_content->getContentSize();
        CCSize zone_size = banner->getContentSize();

        float scale = MIN(zone_size.width/content_size.width,
                          zone_size.height/content_size.height);
        banner_content->setScale(scale);
        banner_content->setAnchorPoint(ccp(0, 0));
        banner_content->setPosition(ccp(0,0));

        item->setContentSize(content_size*scale);
        item->setAnchorPoint(ccp(0.5f,0.5f));
        item->setPosition(zone_size*0.5f);
        item->addChild(banner_content);
    }
}
Beispiel #4
0
bool CCLobbyView::initTopMenu()
{
    CCDirector* director = CCDirector::sharedDirector();
    const CCSize winSize = director->getWinSize();
    const CCSize mySize = this->getContentSize();
    const CCPoint center = ccpMult( ccpFromSize( mySize ), 0.5f );
    
    CCLabelTTF* consoleLabel = CCLabelTTF::create( "disconnected", "Arial", FONT_SIZE(24), CCSizeMake( winSize.width, FONT_SIZE(24) ), kCCTextAlignmentCenter );
    consoleLabel->setColor( ccc3(255, 255, 255) );
    CCMenuItemLabel* consoleItem = CCMenuItemLabel::create( consoleLabel );
    
    // bottom
    const CCSize editSize = CCSizeMake( winSize.width, FONT_SIZE(48) );
    CCMenuItem* editItem = CCMenuItem::create();
    editItem->setContentSize( editSize );
    
    CCMenu* topMenu = CCMenu::create( consoleItem, editItem, NULL );
    if( topMenu )
    {
        this->setConsole( consoleLabel );
        
        topMenu->alignItemsVertically();
        topMenu->setPosition( CCPointMake( center.x, winSize.height - (editItem->getContentSize().height + consoleItem->getContentSize().height)/2 ) );
        this->addChild( topMenu, 0, Child::CCMenu_topMenu );
        
        const CCPoint editItemPosition = editItem->getParent()->convertToWorldSpace( editItem->getPosition() );
        editItem->setContentSize( winSize );
        editItem->ignoreAnchorPointForPosition( false );
        editItem->setAnchorPoint( ccp( 0.5f, (winSize.height / (editItemPosition.y - winSize.height)) * 0.5f ) );
        
        CCScale9Sprite* editSprite = CCScale9Sprite::create("extensions/yellow_edit.png");
        CCEditBox* edit = CCEditBox::create( editSize, editSprite );
        edit->setPlaceHolder("PlayerName");
        edit->setReturnType(kKeyboardReturnTypeDone);
        edit->setFontColor(ccGRAY);
        edit->setMaxLength( 20 );
        edit->setDelegate(this);
        edit->setTouchEnabled( true );
        edit->setPosition( editItemPosition );
        CocosNetworkLogic* network = CocosNetworkLogic::getInstance();
        JString userName = network->getUserName();
        edit->setText(userName.UTF8Representation().cstr());
        this->addChild( edit );
        this->setEditName(edit);
    }
    
    return topMenu;
}
bool SelectLevelScene::init(){
    
    if(!CCScene::init()){
        return false;
    }
    
    CCSprite* bg = CCSprite::create(Images::game::game_bg_jpg);
	addChild(bg, -1);
	bg->setAnchorPoint(ccp(0, 0));
    
	CCMenu* menu = CCMenu::create();
	addChild(menu, 1);
	menu->setAnchorPoint(ccp(0, 0));
	menu->setPosition(ccp(0, 0));
    
	CCMenuItem* backItem = UIUtil::getSingleImageBtn(
                                                     Images::common::back);
	menu->addChild(backItem);
	backItem->setTarget(this, menu_selector(SelectLevelScene::onClickBtn));
	backItem->setTag(-1);
	backItem->setAnchorPoint(ccp(1, 0));
    LayoutUtil::layoutTo(backItem, 0, 1, bg, 0, 1, 4, -4);
    
    _stageImg = CCSprite::create(Images::selectLevel::level1);
    _stageClickedImg = CCSprite::create(Images::selectLevel::level1);
    _stageClickedImgMask = CCSprite::create(Images::selectLevel::level1);
    _stageClickedImgMask->setColor(ccBLACK);
    _stageClickedImgMask->setOpacity(80);
    _stageClickedImg->addChild(_stageClickedImgMask, 1);
    LayoutUtil::layoutToParentCenter(_stageClickedImgMask, _stageClickedImg);
    
    CCMenuItem* stageItem = CCMenuItemSprite::create(_stageImg, _stageClickedImg);
    stageItem->setTarget(this, menu_selector(SelectLevelScene::onClickBtn));
    stageItem->setScale(1.3);
    stageItem->setTag(1);
    menu->addChild(stageItem);
    LayoutUtil::layoutToParentCenter(stageItem, this);
    
    CCMenuItem* leftArrow = UIUtil::getSingleImageBtn(Images::selectLevel::icon_arrow);
    leftArrow->setTarget(this, menu_selector(SelectLevelScene::prev));
    menu->addChild(leftArrow);
    LayoutUtil::layoutTo(leftArrow, 1, 0.5, stageItem, 0, 0.5, -18);
    
    CCSprite* leftArrowBg = CCSprite::create(Images::selectLevel::icon_arrow);
    leftArrowBg->setScale(1.1);
    leftArrowBg->setColor(ccBLACK);
    addChild(leftArrowBg, 0);
    LayoutUtil::layoutToCenter(leftArrowBg, leftArrow);
    
    
    CCMenuItem* rightArrow = UIUtil::getSingleImageBtn(Images::selectLevel::icon_arrow);
    rightArrow->setTarget(this, menu_selector(SelectLevelScene::next));
    menu->addChild(rightArrow);
    rightArrow->setScaleX(-1);
    LayoutUtil::layoutTo(rightArrow, 0, 0.5, stageItem, 1, 0.5, 18);
    
    CCSprite* rightArrowBg = CCSprite::create(Images::selectLevel::icon_arrow);
    rightArrowBg->setScaleX(-1.1);
    rightArrowBg->setScaleY(1.1);
    rightArrowBg->setColor(ccBLACK);
    addChild(rightArrowBg, 0);
    LayoutUtil::layoutToCenter(rightArrowBg, rightArrow);
    
    _stageIndexText = CCLabelTTF::create("01/11", "arial-bold", 30);
    _stageIndexText->setColor(ccBLACK);
    addChild(_stageIndexText, 1);
    LayoutUtil::layoutTo(_stageIndexText, 0.5, 0, stageItem, 0.5, 1, 0, -20);
    
    CCLabelTTF* title = CCLabelTTF::create("选择难度", "arial-bold", 38);
    title->setColor(ccBLACK);
    addChild(title, 1);
    LayoutUtil::layoutTo(title, 0.5, 0, _stageIndexText, 0.5, 1, 0, 20);
    
    MusicBtn* musicBtn = MusicBtn::create();
    addChild(musicBtn, 1);
	LayoutUtil::layoutTo(musicBtn, 0, 0, bg, 0, 0, 5, 5);
    
    _curLevel = 0;
    
    AdUtil::showAd();
    
    return true;
}
bool SelectStageScene::init(int level){
    
    if(!CCScene::init()){
        return false;
    }
    
    _selectLevel = level;
    
    CCSprite* bg = CCSprite::create(Images::game::game_bg_jpg);
	addChild(bg, -1);
	bg->setAnchorPoint(ccp(0, 0));
    
	CCMenu* menu = CCMenu::create();
	addChild(menu, 1);
	menu->setAnchorPoint(ccp(0, 0));
	menu->setPosition(ccp(0, 0));
    
	CCMenuItem* backItem = UIUtil::getSingleImageBtn(
                                                     Images::common::back);
	menu->addChild(backItem);
	backItem->setTarget(this, menu_selector(SelectStageScene::onClickBtn));
	backItem->setTag(-1);
	backItem->setAnchorPoint(ccp(1, 0));
    LayoutUtil::layoutTo(backItem, 0, 1, bg, 0, 1, 4, -4);
    
    CCLabelTTF* title = CCLabelTTF::create("选择关卡", "arial-bold", 38);
    title->setColor(ccBLACK);
    addChild(title, 1);
    LayoutUtil::layoutTo(title, 0.5, 0, bg, 0.5, 1, 0, -110);
    
    CCLabelTTF* subTitleText = CCLabelTTF::create("难度:01/11", "arial-bold", 30);
    subTitleText->setColor(ccBLACK);
    addChild(subTitleText, 1);
    LayoutUtil::layoutTo(subTitleText, 0.5, 1, title, 0.5, 0, 0, -20);
    
    CCSize midSize = CCSize(400, 400);
    
    _midArea = CCNode::create();
    _midArea->setContentSize(midSize);
    addChild(_midArea, 1);
    LayoutUtil::layoutToCenter(_midArea, bg, 0, -30);

    
    for (int i = 0; i < 16; i++) {
        
        int row = i / 4;
        int col = i % 4;
        
        _grids[i] = UIUtil::getSingleImageBtn(Images::selectLevel::unlock);
        _grids[i]->setTarget(this, menu_selector(SelectStageScene::onClickBtn));
        menu->addChild(_grids[i]);
        LayoutUtil::layoutTo(_grids[i], 0.5, 0.5, _midArea, 0.5, 1, (col - 1.5f) * (midSize.width * 0.25f), (-row - 0.5) * (midSize.height * 0.25f));
        
        _gridTexts[i] = CCLabelTTF::create("1", "arial", 32);
        _gridTexts[i]->setColor(ccBLACK);
        addChild(_gridTexts[i], 9);
        LayoutUtil::layoutToCenter(_gridTexts[i], _grids[i]);
        
        _gridLocks[i] = UIUtil::getSingleImageBtn(Images::selectLevel::lock);
        menu->addChild(_gridLocks[i]);
        LayoutUtil::layoutToCenter(_gridLocks[i], _grids[i]);
        
        _grids[i]->setVisible(false);
    }
    
    CCMenuItem* leftArrow = UIUtil::getSingleImageBtn(Images::selectLevel::icon_arrow);
    leftArrow->setTarget(this, menu_selector(SelectStageScene::prev));
    menu->addChild(leftArrow);
    LayoutUtil::layoutTo(leftArrow, 1, 0.5, _midArea, 0, 0.5, 0);
    
    CCSprite* leftArrowBg = CCSprite::create(Images::selectLevel::icon_arrow);
    leftArrowBg->setScale(1.1);
    leftArrowBg->setColor(ccBLACK);
    addChild(leftArrowBg, 0);
    LayoutUtil::layoutToCenter(leftArrowBg, leftArrow);
    
    
    CCMenuItem* rightArrow = UIUtil::getSingleImageBtn(Images::selectLevel::icon_arrow);
    rightArrow->setTarget(this, menu_selector(SelectStageScene::next));
    menu->addChild(rightArrow);
    rightArrow->setScaleX(-1);
    LayoutUtil::layoutTo(rightArrow, 0, 0.5, _midArea, 1, 0.5, 0);
    
    CCSprite* rightArrowBg = CCSprite::create(Images::selectLevel::icon_arrow);
    rightArrowBg->setScaleX(-1.1);
    rightArrowBg->setScaleY(1.1);
    rightArrowBg->setColor(ccBLACK);
    addChild(rightArrowBg, 0);
    LayoutUtil::layoutToCenter(rightArrowBg, rightArrow);
    
    cocos2d::extension::CCScale9Sprite* numBg = cocos2d::extension::CCScale9Sprite::create(CCRect(16, 16, 2, 2), Images::common::numBg);
    numBg->setContentSize(CCSize(110, numBg->getContentSize().height));
    addChild(numBg, 1);
    LayoutUtil::layoutTo(numBg, 1, 0, _midArea, 1, 1, 60, 5);
    
    char temp[32];
    sprintf(temp, "%d/%d", _curPage + 1, _totalPages);
    
    _indexText = CCLabelTTF::create("1/1", "arial", 26);
    _indexText->setAnchorPoint(ccp(1, 0));
    addChild(_indexText, 1);
    LayoutUtil::layoutTo(_indexText, 1, 0.5, numBg, 0.7, 0.5, 0, 0);
    
    sprintf(temp, "难度:%02d/11", _selectLevel);
    subTitleText->setString(temp);
    
    MusicBtn* musicBtn = MusicBtn::create();
    addChild(musicBtn, 1);
	LayoutUtil::layoutTo(musicBtn, 0, 0, bg, 0, 0, 5, 5);
    
    updateStage();
    
    AdUtil::showAd();
    
    return true;
}
CCLayer* RemindLayer::createRLayer(const char *tStr, int remindType){
    CCLayer* layer = new CCLayer();
    int tagOpen = 0;
    int tagClose = 0;
    bool typeOn;
    switch (remindType) {
        case EN_REMIND_ACTIVITY:
            tagOpen = kActivityOnTag;
            tagClose = kActivityOffTag;
            typeOn = CGameData::Inst()->isActivityRemind;
            break;
        case EN_REMIND_TWOUP:
            tagOpen = kTwoupOnTag;
            tagClose = kTwoupOffTag;
            typeOn = CGameData::Inst()->isTwoUpRemind;
            break;
        case EN_REMIND_CNTRYCD:
            tagOpen = kCntryCdOnTag;
            tagClose = kCntryCdOffTag;
            typeOn = CGameData::Inst()->isCntryCdRemind;
            break;
        case EN_REMIND_POWER:{
            tagOpen = kPowerOnTag;
            tagClose = kPowerOffTag;
            typeOn = CGameData::Inst()->intPowerRemind;

            CCSprite* spMenu1 = CCSprite::spriteWithFile("pushConfig_tilizhi.png");
            CCSprite* spMenu2 = CCSprite::spriteWithFile("pushConfig_tilizhi.png");
            CCMenuItem* item = CCMenuItemImage::itemFromNormalSprite(spMenu1,spMenu2,
                                                                      this, menu_selector(RemindLayer::MoveUpKeyboard));
            item->setPosition(ccp(0,0));
            item->setAnchorPoint(CCPointZero);
            CCMenu *menu = CCMenu::menuWithItems (item, NULL);
            menu->setPosition(ccp(-50,20));
            layer->addChild(menu, 2);
            
            char buf[100];
            snprintf(buf, 99,"%d", CGameData::Inst()->intPowerRemind);
            powerNumber = CCTextFieldTTF::textFieldWithPlaceHolder(buf,CCSizeMake(100, 200) ,CCTextAlignmentCenter,"huakangfont.ttf", 32);
            powerNumber->setPosition(ccp(12, 40));
            powerNumber->setColor(ccWHITE);
            powerNumber->setDelegate(this);
            layer->addChild(powerNumber,10);
            CCEGLView * pGlView = CCDirector::sharedDirector()->getOpenGLView();
            pGlView->setIMEKeyboardNumber();
            break;
        }
        default:
            tagOpen = kActivityOnTag;
            tagClose = kActivityOffTag;
            typeOn = CGameData::Inst()->isCntryCdRemind;
            break;
    }
    CCSprite* spFrame = CCSprite::spriteWithFile("pushConfig_Bg.png");
    spFrame->setPosition(CCPointMake(2, 0));
    layer->addChild(spFrame);
    TextNode *remindLabel = TextNode::textWithString(tStr, 32);
    remindLabel->setColor(ccc3(255, 255, 255));
    remindLabel->setShadowColor(ccc3(0, 0, 0));
    remindLabel->setPosition(ccp(0,40));
    layer->addChild(remindLabel);
    
    CCSprite* spMenu1 = CCSprite::spriteWithSpriteFrameName("fr_open.png");
    CCSprite* spMenu2 = CCSprite::spriteWithSpriteFrameName("fr_open.png");
    CCSprite* spMenu3 = CCSprite::spriteWithSpriteFrameName("fr_open2.png");
    CCMenuItem* item1 = CCMenuItemImage::itemFromNormalSprite(spMenu1,spMenu2,spMenu3,
                                                          this, menu_selector(RemindLayer::switchOnOff));
    item1->setPosition(ccp(-170, -50));
    item1->setAnchorPoint(ccp(0, 0));
    item1->setTag(tagOpen);
    
    spMenu1 = CCSprite::spriteWithSpriteFrameName("fr_close.png");
    spMenu2 = CCSprite::spriteWithSpriteFrameName("fr_close.png");
    spMenu3 = CCSprite::spriteWithSpriteFrameName("fr_close2.png");
    CCMenuItem* item2 = CCMenuItemImage::itemFromNormalSprite(spMenu1,spMenu2,spMenu3,
                                                           this, menu_selector(RemindLayer::switchOnOff));
    item2->setPosition(ccp(30, -50));
    item2->setAnchorPoint(ccp(0, 0));
    item2->setTag(tagClose);
    
    item1->setIsEnabled(!typeOn);
    item2->setIsEnabled(typeOn);
    
    CCMenu *menu = CCMenu::menuWithItems (item1,item2,
                                          NULL);
    menu->setPosition(ccp(0, 0));
    layer->addChild(menu);
    return layer;
}
void CompGachaBtn::addHead()
{
    isExchangeAble =true;
    int specailH=0;
    if(cardLines == 1)
        specailH = 40;
    char buf[50];
    
    for(int i=0;i<m_compGachaInfo->material->count();i++)
    {
        CCSprite *head = CGameData::Inst()->getHeadSprite(m_compGachaInfo->material->getObjectAtIndex(i)->cid);
        addChild(head,1000);
        head->setPosition(CCPoint(-190+105*(i%3),-80-(i/3)*110-specailH));
        head->setTag(MATERIALTAG+i);  
        if(!m_compGachaInfo->material->getObjectAtIndex(i)->isOwe)
        {
            head->setOpacity(128);
            isExchangeAble =false;
        }
        if(m_compGachaInfo->material->getObjectAtIndex(i)->isNew)
        {
            showNewCardEffect(head);

        }
    }
    
    CCSprite *targetHead;
    if(m_compGachaInfo->isHide)
    {
        sprintf(buf, "fr_query_box.PNG");
        targetHead = CCSprite::spriteWithFile(buf);
        m_ret.isUnKnowHero = true;
    }
    else 
    {   
        targetHead = CGameData::Inst()->getHeadSprite(m_compGachaInfo->targetCid);
        m_ret.isUnKnowHero = false;

    }
    addChild(targetHead,1000);
    targetHead->setPosition(CCPoint(160,-80));
    targetHead->setTag(SUPERHEROTAG);
    
    CCSprite *normalSp;
    CCSprite *selectedSp ;
    if(isExchangeAble)
    {
        normalSp = CCSprite::spriteWithFile("cg_button_1.png");
        selectedSp =  CCSprite::spriteWithFile("cg_button_1.png");
        
    }else {
        normalSp = CCSprite::spriteWithFile("cg_button_2.png");
        selectedSp =  CCSprite::spriteWithFile("cg_button_2.png");
        
        if(!m_compGachaInfo->isHide)
        {
            targetHead->setOpacity(128);
        }
    }
    
    CCMenuItem *item = CCMenuItemImage::itemFromNormalSprite(normalSp, selectedSp, this, menu_selector(CompGachaBtn::menuCallback));  
    item->setAnchorPoint(CCPoint(0, 0));
    CCMenu *menu = CCMenu::menuWithItem(item);
    menu->setPosition(ccp(targetHead->getPosition().x-70,targetHead->getPosition().y-145));
    addChild(menu);
    
    
}