Ejemplo n.º 1
0
bool ProceedController::init(){
    if (!CCLayer::init()) {
        return false;
    }
    
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    
    //暂停按钮
    CCMenuItemSprite *pause = this->instanceButton("pause1.png", "pause2.png", menu_selector(ProceedController::gamePauseFunc));
    pause->setScale(1.5f);
    pause->setPosition(ccp(size.width - pause->getContentSize().width,
                           size.height - pause->getContentSize().height));
    
    //跳跃按钮
    CCMenuItemSprite *jump = this->instanceButton("control_btn1.png", "control_btn2.png", menu_selector(ProceedController::gameJumpFunc));
    jump->setScale(1.6f);
    jump->setPosition(ccp(size.width - jump->getContentSize().width - 50, 100));
    
    //fever按钮
    CCMenuItemSprite *fever = this->instanceButton("Fever_1_1.png", "Fever_1_1.png",menu_selector(ProceedController::gameFeverFunc));
    fever->setScale(1.5f);
    fever->setOpacity(0.0f);
    fever->setPosition(ccp(jump->getPosition().x - fever->getContentSize().width * 2.0,
                           jump->getPosition().y));
    
    CCMenu *menu = CCMenu::create(pause,jump,fever,NULL);
    menu->setPosition(0, 0);
    this->addChild(menu,80);
    
    return true;
}
void GameOverLayer::createPlayAgainButton()
{
    // Create the startButton
    CCSprite *playAgainButtonSpriteUp = CCSprite::createWithSpriteFrameName("playagain_button.png");
    CCSprite *playAgainButtonSpriteDown = CCSprite::createWithSpriteFrameName("playagain_button.png");
    // Scale the down to 90% so that it looks like the button was pressed
    playAgainButtonSpriteDown->setScale(0.9f);
    CCMenuItemSprite *playAgainButton = CCMenuItemSprite::create(playAgainButtonSpriteUp, playAgainButtonSpriteDown, this, menu_selector(GameOverLayer::playAgainButtonTouched));
    playAgainButton->setPositionX(-playAgainButton->getContentSize().width/1.2);
    playAgainButton->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(1.0f, 1.2f), CCScaleTo::create(1.0f, 1.0f))));
    
    // Create the mainButton
    CCSprite *mainButtonSpriteUp = CCSprite::createWithSpriteFrameName("main_button.png");
    CCSprite *mainButtonSpriteDown = CCSprite::createWithSpriteFrameName("main_button.png");
    // Scale the down to 90% so that it looks like the button was pressed
    mainButtonSpriteDown->setScale(0.9f);
    CCMenuItemSprite *mainButton = CCMenuItemSprite::create(mainButtonSpriteUp, mainButtonSpriteDown, this, menu_selector(GameOverLayer::mainButtonTouched));
    mainButton->setPositionX(mainButton->getContentSize().width/1.2);
    
    // Create the start game menu
    CCMenu *gameMenu = CCMenu::create(playAgainButton, mainButton, NULL);
    // Set the initial position off screen
    gameMenu->setPosition(ccp(SCREEN_WIDTH/2, -SCREEN_HEIGHT));
    // Set the tag of the start menu so that we can refer to it later using getChildByTag(...)
    gameMenu->setTag(kGameOverLayer_PlayAgainMenu);
    
    // Create and run an animation that will slide the start game menu in from below the screen to its intended location
    CCActionInterval *moveAction = CCMoveTo::create(0.3f, ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.15));
    CCFiniteTimeAction *easeIn = CCEaseIn::create(moveAction, 0.2f);
    gameMenu->runAction(easeIn);
    
    // Add the start menu to the layer
    this->addChild(gameMenu);
}
Ejemplo n.º 3
0
bool PanelLayer::init()
{
    if (CCLayer::init()) {
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        
        _goldCounterLayer = GoldCounterLayer::create();
        this->addChild(_goldCounterLayer);
        
        ScheduleCountDown *scheduleCountDown = ScheduleCountDown::create(this);
        _scheduleLabel = CCLabelTTF::create("60", "Thonburi", 16);
        _scheduleLabel->addChild(scheduleCountDown);
        this->addChild(_scheduleLabel);
        
        CCMenuItemSprite *pause = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName(STATIC_DATA_STRING("pause_normal")), CCSprite::createWithSpriteFrameName(STATIC_DATA_STRING("pause_selected")), this, menu_selector(PanelLayer::pause));
        CCMenu *menu = CCMenu::create(pause, NULL);
        this->addChild(menu);
        
        _goldCounterLayer->setPosition(CCPointMake(winSize.width*0.05f, winSize.height*0.05f));
        _scheduleLabel->setPosition(CCPointMake(winSize.width*0.3f, winSize.height*0.05f));
        CCSize pauseSize = pause->getContentSize();
        menu->setPosition(CCPointMake(winSize.width-pauseSize.width*0.5f, pauseSize.height*0.5f));
        
        
        return true;
    }
    return false;
}
Ejemplo n.º 4
0
void BYGameScene::loadUI() {
    
    CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
    frameCache->addSpriteFramesWithFile("ui.plist", "ui.png");
    
    CCSize winSize    = CCDirector::sharedDirector()->getWinSize();    
    
    /// pause button
    CCSprite* btnNormalSprite = CCSprite::createWithSpriteFrameName("pause.png");
    CCMenuItemSprite *pauseMenuItem = CCMenuItemSprite::create(btnNormalSprite,
                                                               btnNormalSprite,
                                                               this,
                                                               menu_selector(BYGameScene::pauseButtonHandler));
    
    /// 2 labels for goals
    ccColor3B color = ccc3(220, 70, 20); /// red color
    _labelBotPlayerGoalsScored = CCLabelTTF::create("0", "Marker Felt", 40);
    _labelBotPlayerGoalsScored->setColor(color);
    CCMenuItemLabel *labelBot = CCMenuItemLabel::create(_labelBotPlayerGoalsScored, NULL, NULL);
    labelBot->setEnabled(false);
    
    _labelTopPlayerGoalsScored = CCLabelTTF::create("0", "Marker Felt", 40);
    _labelTopPlayerGoalsScored->setColor(color);
    CCMenuItemLabel *labelTop = CCMenuItemLabel::create(_labelTopPlayerGoalsScored, NULL, NULL);
    labelTop->setEnabled(false);
    
    /// CCMenu doesnt support anchorPoint as of 0x00020003 version
    CCMenu *menu = CCMenu::create(labelTop, pauseMenuItem, labelBot, NULL);
    menu->alignItemsHorizontallyWithPadding(5);
    menu->setAnchorPoint(CCPointMake(0, 0));
    menu->setPosition(CCPointMake(winSize.width - pauseMenuItem->getContentSize().width / 2,
                                  winSize.height / 2));
    menu->setRotation(90);
    this->addChild(menu);
}
Ejemplo n.º 5
0
void MyBuildingCard::displayDetail(cocos2d::CCNode *psender){
    MyBuildingCard* card = (MyBuildingCard*)psender->getParent()->getParent();
    activeCard = card;
    oriPosition = card->getPosition();
    card->runAction(CCEaseInOut::create(CCMoveTo::create(0.2, ccp(200-card->getParent()->getPosition().x,320)),2));
    card->runAction(CCEaseInOut::create(CCScaleTo::create(0.2, 1.2),2));
    card->isEnabled = false;
    ((GXScrollView*)(card->getParent()))->setEnabled(false);
    card->getParent()->reorderChild(card, 100000);
    CCMenuItemSprite* gray = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("dialoggray.png"), CCSprite::createWithSpriteFrameName("dialoggray.png"));
    MyPriorityMenu* grayMenu = MyPriorityMenu::create(-503,gray,NULL);
    grayMenu->setTag(grayTag);
    card->getParent()->addChild(grayMenu,99999);
    gray->setScaleX(960/gray->getContentSize().width);
    gray->setScaleY(540/gray->getContentSize().height);
    grayMenu->setPosition(ccp(480-card->getParent()->getPosition().x,320));
//    gray->setPosition(ccp(0,0));
    
    CCSprite* detailBack = CCSprite::createWithSpriteFrameName("creatoruidetail.jpg");    detailBack->setPosition(ccp(634-card->getParent()->getPosition().x,-detailBack->getContentSize().height/2-100));
    detailBack->setScale(1.2);
    detailBack->setTag(detailBackTag);
    card->getParent()->addChild(detailBack,100000);
    detailBack->runAction(CCSequence::create(CCDelayTime::create(0.2),CCEaseInOut::create(CCMoveTo::create(0.2, ccp(634-card->getParent()->getPosition().x,320)),2), NULL));
    CCMenuItemFont::setFontSize(24);
    CCMenuItemFont* back = CCMenuItemFont::create("返回",this,menu_selector(MyBuildingCard::cancelDetail));
    back->setColor(ccc3(114,66,45));
    MyPriorityMenu* backMenu = MyPriorityMenu::create(-503,back,NULL);
    backMenu->setPosition(ccp(detailBack->getContentSize().width-44,44));
    detailBack->addChild(backMenu,NULL);
}
Ejemplo n.º 6
0
// on "init" you need to initialize your instance
bool AchievementLayer::init() {
	if (!CCLayerColor::initWithColor(ccc4(100, 255, 255, 255)))
		return false;
	_achievementAchievementsLayer = NULL;

	//adding the background
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	cocos2d::CCSprite* backgroundArt = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("menuBackground.png"));

	float bgScale = winSize.height / backgroundArt->getContentSize().height;
	backgroundArt->setScale(bgScale);

	float diff = winSize.width - backgroundArt->getContentSize().width * bgScale;
	float x = backgroundArt->getContentSize().width / 2 * bgScale + diff / 2;
	float y = backgroundArt->getContentSize().height / 2 * bgScale;
	backgroundArt->setPosition(ccp(x, y));
	addChild(backgroundArt);

	float scaleMult = Model::getInstance()->getGUIElementScaleMultiplicator();
	//back button
	int buttonHeight = 66 * scaleMult;
	int buttonLength = 66 * scaleMult;
	CCMenu* backButtonmenu = CCMenu::create();
	CCMenuItemSprite *backButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("return0.png"),
			CCSprite::createWithSpriteFrameName("return1.png"), (CCObject*) this, menu_selector(AchievementLayer::backTouched));
	backButton->setScaleX(buttonLength / backButton->getContentSize().width);
	backButton->setScaleY(buttonHeight / backButton->getContentSize().height);
	backButtonmenu->addChild(backButton);

	CCMenuItemSprite *toggleModeButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("toggleGUI1.png"),
			CCSprite::createWithSpriteFrameName("toggleGUI2.png"), (CCObject*) this, menu_selector(AchievementLayer::toggleModeTouched));
	toggleModeButton->setScaleX(buttonLength / toggleModeButton->getContentSize().width);
	toggleModeButton->setScaleY(buttonHeight / toggleModeButton->getContentSize().height);
	backButtonmenu->addChild(toggleModeButton);

	float padding = 10 * scaleMult;
	backButtonmenu->alignItemsVerticallyWithPadding(padding);
	addChild(backButtonmenu);
	backButtonmenu->setPosition(CCPoint(winSize.width - buttonLength / 2, winSize.height - (buttonHeight * 2.0f + padding) / 2));

	float offsetDown = ViewTools::addVersionAndCreditInfo(this, scaleMult);
	ViewTools::addIdleUnitTo(this, offsetDown);

	return true;
}
Ejemplo n.º 7
0
bool PanelLayer::init()
{
    if(CCLayer::init()){
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        
        CCMenuItemSprite* pause = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName(STATIC_DATA_STRING("pause_normal")), CCSprite::createWithSpriteFrameName(STATIC_DATA_STRING("pause_selected")),this,menu_selector(PanelLayer::pause));
        CCMenu* menu = CCMenu::create(pause, NULL);
        this->addChild(menu);
        
        CCSize pauseSize = pause->getContentSize();
        menu->setPosition(CCPointMake(winSize.width-pauseSize.width*0.5, pauseSize.height*0.5));

        return true;
    }
    return false;
}
Ejemplo n.º 8
0
CCMenuItemSprite *CWaterpump::initMenuItemWithFiles(int type, const char *normal, const char *selected, const char *disable, SEL_MenuHandler selector)
{
    CCSprite *pNormal = CCSprite::create(normal);
    CCSprite *pSelected = CCSprite::create(selected);
    CCSprite *pDisable = CCSprite::create(disable);

    CCMenuItemSprite *pItem = CCMenuItemSprite::create(pNormal, pSelected, pDisable, this, selector);
    int cnt = CPlayerAccount::GetAccountInstance()->GetAccountPropsNum(type);
    char szCntStr[8] = {0};
    sprintf(szCntStr, "%d", cnt);
    CCLabelAtlas *pCntFnt = CCLabelAtlas::create(szCntStr, "UI_02_05.png", 48, 57, '0');
    pCntFnt->setAnchorPoint(ccp(1, 0));
    pCntFnt->setPosition(ccp(pItem->getContentSize().width, 0));
    pItem->addChild(pCntFnt, 1, Tag_ItemFnt);
    pItem->setTag(type);
    return pItem;
}
Ejemplo n.º 9
0
CCMenuItemSprite* CCLayerParent::getSpriteButton(int tag,int price,const char* frameName,SEL_MenuHandler selector)
{	
 	CCSize winSize = CCDirector::sharedDirector()->getWinSize();

    CCMenuItemSprite *quirkButton =  CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("spawn.png"),CCSprite::createWithSpriteFrameName("spawn_sel.png"),this,selector);
    CCSize contentSize =  quirkButton->getContentSize();
	//quirkButton->setPosition (ccp(contentSize.width* tag, contentSize.height/2));
	quirkButton->setTag(tag);
    CCSprite* quirk = CCSprite::createWithSpriteFrameName(frameName);
	quirk->setPosition(ccp(quirk->getContentSize().width/2, contentSize.height-quirk->getContentSize().height/2));
    quirkButton->addChild(quirk);
    char temp[64];
    sprintf(temp, "%d", price);

    //CCLabel* quirkLabel = CCLabelBMFont::create(temp,"Courier_green.fnt");
	CCLabelTTF* quirkLabel = CCLabelTTF::create(temp, "Helvetica-Bold", fontSizeBig, ccp(xMARGIN,yMARGIN), kCCTextAlignmentCenter );
	quirkLabel->setColor(ccc3(255,255,255));
    quirkLabel->setPosition(ccp(quirk->getContentSize().width/2, yMARGIN*0.4));
    quirkButton->addChild(quirkLabel);
	quirkButton->setZOrder(3);
	return quirkButton;
}
Ejemplo n.º 10
0
bool StageMapLayer::init()
{
    if(!CCLayer::init())
        return false;
    
    this->ignoreAnchorPointForPosition(false);
    this->setAnchorPoint(AnchorPointLeftBottom);
    
    this->setTouchEnabled(true);
    this->setTouchMode(kCCTouchesOneByOne);
    
    const CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    // Background
    m_Background = CCSprite::createWithSpriteFrameName("mainscene_background.png");
    m_Background->retain();
    m_Background->cocos2d::CCNode::setPosition(winSize.width / 2, winSize.height / 2);
    
    for(int i=0; i<5; ++i)
    {
        CCString* fileName = CCString::createWithFormat("mainscene_cloud%d.png", i+1);
        m_BackgroundCloud[i] = CCSprite::createWithSpriteFrameName(fileName->getCString());
        m_BackgroundCloud[i]->retain();
        m_Background->addChild(m_BackgroundCloud[i]);
        
        CCPoint initialPosition = CCPointMake(RandomNumberGenerator::Int(0, static_cast<INT>(winSize.width)), RandomNumberGenerator::Int(30.f, INT(winSize.height*0.9f)));
        m_BackgroundCloud[i]->setPosition(initialPosition);
        
            // Cloud Moving Animation
        const CCSize cloudSize = m_BackgroundCloud[i]->getContentSize();
        const float speed = 5+ static_cast<float>(RandomNumberGenerator::Int(0, 25));   // pixel/sec
        const float timeToLeftEnd = (initialPosition.x+cloudSize.width*0.5f)/speed;
        const float timeToRepeatLeft = (winSize.width+cloudSize.width)/speed;
        CCSprite* cloudNode = m_BackgroundCloud[i];
        CCMoveTo* moveToLeftEnd = CCMoveTo::create(timeToLeftEnd, ccp(-cloudSize.width*0.5f, initialPosition.y));
        CCCallFuncL* moveToRightEnd = CCCallFuncL::create([winSize, cloudNode, cloudSize, initialPosition]()
                                                          {
                                                              if( cloudNode )
                                                              {
                                                                  cloudNode->setPosition(ccp(winSize.width+cloudSize.width*0.5f,initialPosition.y));
                                                              }
                                                          });
        CCMoveTo* moveToLeftEndRepeat = CCMoveTo::create(timeToRepeatLeft, ccp(-cloudSize.width*0.5f, initialPosition.y));
        CCSequence* moveToRightAndLeftEnd = CCSequence::create(moveToRightEnd, moveToLeftEndRepeat, nullptr);
        CCRepeat* moveToRightAndLeftEndRepeat = CCRepeat::create(moveToRightAndLeftEnd, 20);
        CCSequence* moveSeq = CCSequence::create(moveToLeftEnd, moveToRightAndLeftEndRepeat, nullptr);
        cloudNode->runAction(moveSeq);
            // End Cloud Moving Animation
    }
    
    m_Top = CCSprite::createWithSpriteFrameName("mainscene_top.png");
    m_Top->retain();
    const CCSize topSpriteSize = m_Top->getContentSize();
    m_Top->setPosition(ccp(winSize.width*0.5f, winSize.height-topSpriteSize.height*0.5f));
    
    m_Bottom = CCSprite::createWithSpriteFrameName("mainscene_bottom.png");
    m_Bottom->retain();
    const CCSize bottomSpriteSize = m_Bottom->getContentSize();
    m_Bottom->setPosition(ccp(winSize.width*0.5f, bottomSpriteSize.height*0.5f));
    //End Background
    this->addChild(m_Background, StageMapLayerDepth_Background);
    this->addChild(m_Top, StageMapLayerDepth_UIComponents);
    this->addChild(m_Bottom, StageMapLayerDepth_UIComponents);
    
    
    // Number Of Carrots
    m_Carrot = CCSprite::createWithSpriteFrameName("mainscene_carrot_stat.png");
    m_Carrot->retain();
    const CCSize carrotSize = m_Carrot->getContentSize();
    m_Carrot->setPosition(ccp( 5.f+carrotSize.width/2.f, winSize.height-carrotSize.height/2.f-5.f));
    this->addChild(m_Carrot, StageMapLayerDepth_UIComponents);
    
    m_Clover = CCSprite::createWithSpriteFrameName("mainscene_clover_stat.png");
    m_Clover->retain();
    const CCSize cloverSize = m_Clover->getContentSize();
    m_Clover->setPosition(ccp( 5.f + carrotSize.width +10.f + cloverSize.width*0.5f, winSize.height-cloverSize.height*0.5f - 5.f));
    this->addChild(m_Clover, StageMapLayerDepth_UIComponents);
    
    User* myUser = GooRoomClient::Instance().GetUser();
    if( myUser != nullptr )
    {
        m_NumberOfCarrots = CCLabelTTF::create(CCString::createWithFormat("%lld",myUser->GetGold())->getCString(), fontList[0].c_str(), 13);
        m_NumberOfCarrots->retain();
        m_NumberOfCarrots->setColor(ccBLACK);
        const CCSize numberOfCarrotsSize = m_NumberOfCarrots->getContentSize();
        m_NumberOfCarrots->setPosition(ccp(5.f+carrotSize.width*0.5f, m_Carrot->getPositionY()-2.f));
        this->addChild(m_NumberOfCarrots, StageMapLayerDepth_UIComponents);
    }
    // END BASE


    m_MapBase = CCNode::create();
    m_MapBase->retain();
    m_MapBase->setContentSize(winSize);
    m_MapBase->setAnchorPoint(AnchorPointMidBottom);
    m_MapBase->setPosition(ccp(winSize.width/2.f, 0.f));
    this->addChild(m_MapBase,StageMapLayerDepth_MapBase);
    
    m_StageInfoBox = CCSprite::createWithSpriteFrameName("stagemap_info_box.png");
    m_StageInfoBox->retain();
    m_StageInfoBox->setAnchorPoint(AnchorPointMid);
    const CCSize stageInfoBoxSize = m_StageInfoBox->getContentSize();
    m_StageInfoBox->setPosition(ccp(winSize.width*0.5f, stageInfoBoxSize.height*0.5f));
    m_Bottom->addChild(m_StageInfoBox,StageMapLayerDepth_UIComponents);

    StageInfoDictionary::Instance().ForEachStageInfo([this](StageInfo* stageInfo)
    {
        this->AddStageMapPoint(*stageInfo);
    });
    
    CharacterData characterData = *CharacterDictionary::Instance().GetCharacterData(GooRoomClient::Instance().GetUser()->GetSelectedCharacterType());
    characterData.SetLevel(GooRoomClient::Instance().GetUser()->GetSelectedCharacterCard().GetLevel());
    m_MyPlayer = PlayerNode::create(characterData, ActorID_None, GooRoomClient::Instance().GetUser()->GetUserName().c_str(), TeamType_None);
    m_MyPlayer->retain();
    m_MyPlayer->setPosition((m_StageMapPointList.front()->getPosition()+m_PlayerPositionOffset));
    m_MyPlayer->setAnchorPoint(CharacterAnchorPoint);
    m_MapBase->addChild(m_MyPlayer);
    
    StageInfo* stageInfo = StageInfoDictionary::Instance().FindStageInfo(0);
    m_MissionBox = MissionBox::create(*stageInfo);
    m_MissionBox->retain();
    m_MissionBox->setAnchorPoint(AnchorPointLeftBottom);
    const CCSize missionBoxSize = m_MissionBox->getContentSize();
    m_MissionBox->setPosition(ccp(missionBoxSize.width*0.5f, missionBoxSize.height*0.5f));
    this->addChild(m_MissionBox, StageMapLayerDepth_UIComponents);
    
    m_TitleBox = TitleBox::create(*stageInfo);
    m_TitleBox->retain();
    m_TitleBox->setAnchorPoint(AnchorPointLeftBottom);
    const CCSize titleBoxSize = m_TitleBox->getContentSize();
    m_TitleBox->setPosition(ccp(winSize.width-titleBoxSize.width*0.5f, titleBoxSize.height*0.5f+5.f));
    this->addChild(m_TitleBox, StageMapLayerDepth_UIComponents);


    // Create Button
    m_CreateStage = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("create_button.png"), CCSprite::createWithSpriteFrameName("create_button_pushed.png"), this, menu_selector(StageMapLayer::OnCreateStageTouch));
    m_CreateStage->retain();
    m_MenuCreateStage = CCMenu::create(m_CreateStage, nullptr);
    m_MenuCreateStage->retain();
    m_MenuCreateStage->setAnchorPoint(AnchorPointMid);
    const CCSize menuItemSize = m_CreateStage->getContentSize();
    m_MenuCreateStage->setPosition(ccp(winSize.width-menuItemSize.width/2.f-40.f, menuItemSize.height/2.f+10.f));
    this->addChild(m_MenuCreateStage, StageMapLayerDepth_UIComponents);
    
    // End Create Button

    // Exit Button
    CCMenuItemSprite* exitButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("exit_button.png"),CCSprite::createWithSpriteFrameName("exit_button_pushed.png"), this, menu_selector(StageMapLayer::OnExitButtonTouch));
    CCMenu* exitMenu = CCMenu::create(exitButton, NULL);
    CCSize exitButtonSize = exitButton->getContentSize();
    exitMenu->setPosition(winSize.width-exitButtonSize.width/2.f-5.f, winSize.height-exitButtonSize.height/2.f-5.f);
    
    this->addChild(exitMenu, StageMapLayerDepth_UIComponents);
    
    // Shop Menu
    {
        CCSprite* shopSprite = CCSprite::createWithSpriteFrameName("mainscene_blank_button.png");
        CCSprite* shopPushedSprite = CCSprite::createWithSpriteFrameName("mainscene_blank_button_pushed.png");
        CCMenuItemSprite* shopButton = CCMenuItemSprite::create(shopSprite, shopPushedSprite, this, menu_selector(StageMapLayer::OnShopButtonTouch));
        CCLabelTTF* shopLabel = CCLabelTTF::create("구르몽 친구들", fontList[0].c_str(), 14);
        shopLabel->setColor(ccBLACK);
        shopLabel->setAnchorPoint(AnchorPointMid);
        const CCSize shopSpriteSize = shopSprite->getContentSize();
        shopLabel->setPosition(ccp(shopSpriteSize.width*0.5f, shopSpriteSize.height*0.5f));
        shopSprite->addChild(shopLabel);
        shopButton->setScale(0.85f);
        
        CCMenu* shopMenu = CCMenu::create(shopButton, nullptr);
        shopMenu->setPosition(ccp(winSize.width-shopSpriteSize.width*0.5f - 5.f, winSize.height-exitButtonSize.height - 5.f -shopSpriteSize.height*0.5f -10.f));
        this->addChild(shopMenu, StageMapLayerDepth_UIComponents);
    }

    
    StageLevel currentStageLevel = GooRoomClient::Instance().GetUser()->GetStageLevel();
    if( currentStageLevel >= m_StageMapPointList.size() )
    {
        currentStageLevel = m_StageMapPointList.size()-1;
    }
    this->SelectStageMapPoint(currentStageLevel-1, false);
    this->SelectStageMapPoint(currentStageLevel, true);
    
    this->scheduleUpdate();
    
    return true;
}
Ejemplo n.º 11
0
void CWaterpump::onEnter()
{
    CCSprite::onEnter();

    CCSize visiableView = CCDirector::sharedDirector()->getWinSize();
    // 距离底部距离, 等同与怒气条的高度
    float fBottomHeight = 65.0f;

    // 监听玩家攻击
    CCNotificationCenter::sharedNotificationCenter()->addObserver(this, 
        callfuncO_selector(CWaterpump::onRoleAttackCallback), 
        MSG_ROLEACOMPLETE, NULL);

    CCSprite *pumpBg = CCSprite::create("UI_01_01.png");
    addChild(pumpBg);
    pumpBg->setPosition(ccp(visiableView.width/2, pumpBg->getContentSize().height/2));
    this->setContentSize(pumpBg->getContentSize());

    // 灌水彩色图
    CCProgressTo *to1 = CCProgressTo::create(3, 100);
    m_pPump = CCProgressTimer::create(CCSprite::create("UI_01_04.png"));
    m_pPump->setAnchorPoint(ccp(0.5f, 0.0f));
    m_pPump->setType(kCCProgressTimerTypeBar);
    m_pPump->setMidpoint(ccp(0,0));
    m_pPump->setBarChangeRate(ccp(0, 1));
    m_pPump->setPosition(ccp(visiableView.width/2 + 1, fBottomHeight));
    m_pPump->runAction(CCRepeatForever::create(to1));
    addChild(m_pPump);

    // 指示针
    m_pIndicator = CCSprite::create("UI_01_05.png");
    m_pIndicator->setAnchorPoint(ccp(0.5f, 0.0f));
    m_pIndicator->setPosition(ccp(visiableView.width/2, fBottomHeight));
    addChild(m_pIndicator);

    // 怒气值
    m_pFuryPower = CCSprite::create("UI_01_03.png", CCRectMake(0,0,1090,44));
    m_pFuryPower->setAnchorPoint(ccp(0.0f, 0.5f));
    ccTexParams params = {GL_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE};
    m_pFuryPower->getTexture()->setTexParameters(&params);
    m_pFuryPower->setPosition(ccp(visiableView.width/2 - 545, 44));
    m_pFuryPower->setScaleX(0.0f);
    addChild(m_pFuryPower, -1);

    CCSprite *pFuryBg = CCSprite::create("UI_01_02.png", CCRectMake(0,0,1090,44));
    pFuryBg->getTexture()->setTexParameters(&params);
    pFuryBg->setPosition(ccp(visiableView.width/2, 44));
    addChild(pFuryBg, -2);

    //菜单
    //普通斧子用来传递给角色数据, 不做显示用
    m_pNormalAxeItem = initMenuItemWithFiles(ROLEID_NORMAXE, szItemNormal[0], szItemSelected[0], szItemDisable[0], menu_selector(CWaterpump::onSelectedMenuItem));
    m_pNormalAxeItem->setVisible(false);

    CCMenuItemSprite *pFireItem = initMenuItemWithFiles(ROLEID_FIREAXE, szItemNormal[0], szItemSelected[0], szItemDisable[0], menu_selector(CWaterpump::onSelectedMenuItem));
    CCMenuItemSprite *pIceItem = initMenuItemWithFiles(ROLEID_ICEAXE, szItemNormal[1], szItemSelected[1], szItemDisable[1], menu_selector(CWaterpump::onSelectedMenuItem));
    CCMenuItemSprite *pBaneItem = initMenuItemWithFiles(ROLEID_BANEAXE, szItemNormal[2], szItemSelected[2], szItemDisable[2], menu_selector(CWaterpump::onSelectedMenuItem));
    CCMenuItemSprite *pWindItem = initMenuItemWithFiles(ROLEID_WINDAXE, szItemNormal[3], szItemSelected[3], szItemDisable[3], menu_selector(CWaterpump::onSelectedMenuItem));

    CCMenu *pMenu = CCMenu::create(m_pNormalAxeItem, pFireItem, pIceItem, pBaneItem, pWindItem, NULL);
    float fItemHeight = pFireItem->getContentSize().height;
    float fItemWidth = pFireItem->getContentSize().width;
    float fPumpWidth = m_pPump->getContentSize().width;
    pFireItem->setPosition(ccp(visiableView.width/2 - fPumpWidth/2 - (1.5f*fItemWidth), fItemHeight/2));
    pIceItem->setPosition(ccp(visiableView.width/2 - fPumpWidth/2 - (0.5f*fItemWidth), fItemHeight/2));
    pBaneItem->setPosition(ccp(visiableView.width/2 + fPumpWidth/2 + (0.5f*fItemWidth), fItemHeight/2));
    pWindItem->setPosition(ccp(visiableView.width/2 + fPumpWidth/2 + (1.5f*fItemWidth), fItemHeight/2));

    pMenu->setPosition(ccp(0, fBottomHeight));
    addChild(pMenu);

    scheduleUpdate();
}
Ejemplo n.º 12
0
// on "init" you need to initialize your instance
bool S11PrepareRes::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    //每个项目都要创建的东西
    
    _menu = CCMenu::create(NULL);
    _menu->setPosition(CCPointZero);
    this->addChild(_menu, 101);
    
    titleString = "";
    
	scriptMap=ScriptParser::paserScript("S11PrepareRes","leftTitle");//right_TableView_Map

    //背景图
    
    {
        CCSprite * aSprite = CCSprite::create("s11Background.png");
        aSprite->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
        //CC_BREAK_IF(! aSprite);
        this->addChild(aSprite,98);
        aSprite ->getTexture()->setAntiAliasTexParameters();//抗锯齿
    }
    //控件
    
    {
        CCSprite * aSprite = CCSprite::create("s11NavBar.png");
        aSprite->setAnchorPoint(ccp(0.0,1.0));
        aSprite->setPosition(ccp(0,visibleSize.height-40));
        this->addChild(aSprite,100);
    }
    
    
    {
        CCLabelTTF * leftTitleLabel = CCLabelTTF::create(s11Str2_macro,s11FontName_macro,s11TitleFontSize_macro);
        CCLabelTTF* pLabel = leftTitleLabel;
        pLabel->setColor(ccWHITE);
        
        pLabel->setPosition( s11Position3_macro(pLabel));
        this->addChild(pLabel, 100);
    }
    
    titleLabel = CCLabelTTF::create(s11Str2_macro,s11FontName_macro,s11TitleFontSize_macro);
    CCLabelTTF* pLabel = titleLabel;
    pLabel->setColor(ccWHITE);
    
    pLabel->setPosition( s11Position4_macro(pLabel));
    this->addChild(pLabel, 100);
    
    
    
    {
        CCSprite * aSprite = CCSprite::create("pRecButton.png");
        aSprite->setPosition(s11Position1_macro(aSprite));
        this->addChild(aSprite,100);
        
        
        CCSprite * aSprite1 = CCSprite::create("s11FullScreenIcon.png");
        aSprite1->setPosition(s11Position1_macro(aItem));
        this->addChild(aSprite1,100);
    
        CCSprite * sprite1 = CCSprite::create();
        CCSprite * sprite2 = CCSprite::create();
        
        CCMenuItemSprite *aItem = CCMenuItemSprite::create(
                                                           sprite1,
                                                           sprite2,
                                                           this,
                                                           menu_selector(S11PrepareRes::menuCloseCallback));
        aItem->setPosition(s11Position1_macro(aItem));
        aItem->setContentSize(aSprite->getContentSize());
        _menu ->addChild(aItem,100);
        
    }

    
    
    CCTableView * tableView = CCTableView::create(this, s11Size1_macro);
    tableView->setAnchorPoint(ccp(0.0,0.0));
    tableView->setDirection(kCCScrollViewDirectionVertical);
    tableView->setPosition(s11Position8_macro(tableView));
    tableView->setDelegate(this);
    tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
    this->addChild(tableView,99);
    tableView->reloadData();
    

    std::string aStr = ScriptParser::readScript("s11TableCellTxt1.txt");
    S11PrepareRes::detailString = aStr;
    rightDetailTex = CCLabelTTF::create(aStr.c_str(), "Helvetica", 30.0);
    rightDetailTex->setColor(ccBLACK);
    rightDetailTex-> setDimensions(s11Size2_macro);
    rightDetailTex->setPosition(s11Position9_macro(label));
    this->addChild(rightDetailTex,100);
    //TabelBar
    
    {
        pTabBar = CCSprite::create("pTabBar.png");
        pTabBar->setAnchorPoint(ccp(0.0,1.0));
        pTabBar->setPosition(CCPointZero);
        this->addChild(pTabBar,100);
    }
    
    m_highlightSp = CCSprite::create("pTabBarSelectedHighlight.png");
    
    {
        m_practiceSprite = CCSprite::create("pPencilIcon.png");
        CCSprite * aSprite = m_practiceSprite;
        aSprite->setPosition(s11Position5_macro(aSprite));
        
        this->addChild(aSprite,100);
        
        CCSprite * sprite1 = CCSprite::create();
        CCSprite * sprite2 = CCSprite::create();
        m_practiceItem = CCMenuItemSprite::create(
                                                  sprite1,
                                                  sprite2,
                                                  this,
                                                  menu_selector(S11PrepareRes::menuselect));
        CCMenuItemSprite *aItem = m_practiceItem ;
        aItem->setTag(2);
        
        
        aItem->setPosition(s11Position5_macro(aItem));
        aItem->setContentSize(m_highlightSp->getContentSize());
        _menu ->addChild(aItem,100);
        
        m_touchedItem = m_practiceItem;
        
        
        m_practiceLabel = CCLabelTTF::create(s11Str1_macro,s11FontName_macro,s11FontSize_macro);
        CCLabelTTF* pLabel = m_practiceLabel;
        pLabel->setColor(s11White_macro);
        pLabel->setAnchorPoint(ccp(0.5,1.0));
        pLabel->setPosition( ccp(aItem->getPosition().x,aItem->getPosition().y-aItem->getContentSize().height/2+11));
        this->addChild(pLabel, 100);
    }
    
    {
        
        m_prepareSprite = CCSprite::create("pDocumentIconActive.png");
        CCSprite * aSprite = m_prepareSprite;
        aSprite->setPosition(s11Position6_macro(aSprite));
        
        this->addChild(aSprite,100);
        
        CCSprite * sprite1 = CCSprite::create();
        CCSprite * sprite2 = CCSprite::create();
        
        m_prepareItem = CCMenuItemSprite::create(
                                                 sprite1,
                                                 sprite2,
                                                 this,
                                                 menu_selector(S11PrepareRes::menuselect));
        CCMenuItemSprite *aItem = m_prepareItem ;
        aItem->setTag(3);
        
        aItem->setPosition(s11Position6_macro(aItem));
        aItem->setContentSize(m_highlightSp->getContentSize());
        _menu ->addChild(aItem,100);
        
        m_prepareLabel = CCLabelTTF::create(s11Str2_macro,s11FontName_macro,s11FontSize_macro);
        CCLabelTTF* pLabel = m_prepareLabel;
        pLabel->setColor(s11Blue_macro);
        pLabel->setAnchorPoint(ccp(0.5,1.0));
        pLabel->setPosition( ccp(aItem->getPosition().x,aItem->getPosition().y-aItem->getContentSize().height/2+11) );
        this->addChild(pLabel, 100);
    }
    
    
    {
        
        m_settingSprite = CCSprite::create("pSettingsIcon.png");
        CCSprite * aSprite = m_settingSprite;
        aSprite->setPosition(s11Position7_macro(aSprite));
        
        this->addChild(aSprite,100);
        
        CCSprite * sprite1 = CCSprite::create();
        CCSprite * sprite2 = CCSprite::create();
        
        
        m_setting = CCMenuItemSprite::create(
                                             sprite1,
                                             sprite2,
                                             this,
                                             menu_selector(S11PrepareRes::menuselect));
        CCMenuItemSprite *aItem = m_setting ;
        aItem->setTag(5);
        
        
        aItem->setPosition(s11Position7_macro(aItem));
        aItem->setContentSize(m_highlightSp->getContentSize());
        _menu ->addChild(aItem,100);
        
        m_settingLabel= CCLabelTTF::create(s11Str3_macro,s11FontName_macro,s11FontSize_macro);
        CCLabelTTF* pLabel = m_settingLabel;
        pLabel->setColor(s11Blue_macro);
        pLabel->setAnchorPoint(ccp(0.5,1.0));
        pLabel->setPosition( ccp(aItem->getPosition().x,aItem->getPosition().y-aItem->getContentSize().height/2+11) );
        this->addChild(pLabel, 100);
    }
    
    m_highlightSp->setPosition(ccp(m_prepareSprite->getPosition().x,pTabBar->getPosition().y+pTabBar->getContentSize().height/2));
    
    this->addChild(m_highlightSp,100);
    m_highlightSp->setColor(ccc3(200, 200, 200));
    
    
    return true;
}
Ejemplo n.º 13
0
void PrepareLayer::initPet(int leftOrRight)
{
	///**初始化已经出战的左边的宠物**///
	int petId = -1;
	for (int i =0;i !=6; ++i )
	{
		if (GameConfigData::initialGameData().getPetStateById(i) == "2")
		{
			if (GameConfigData::initialGameData().getPetPosById(i) == leftOrRight)
			{
				petId = i;
			}
		}
	}

	CCMenuItemSprite *petAddLeft = (CCMenuItemSprite *)m_menu->getChildByTag(100+4+leftOrRight);
	if (petAddLeft->getChildByTag(1000))
	{
		petAddLeft->removeChildByTag(1000);
	}

	CCPoint leftPoint[6] = {petAddLeft->getContentSize()/2+ccp(20*gScaleX,0),petAddLeft->getContentSize()/2+ccp(20*gScaleX,0),petAddLeft->getContentSize()/2+ccp(30*gScaleX,0),
		petAddLeft->getContentSize()/2+ccp(30*gScaleX,0),petAddLeft->getContentSize()/2+ccp(30*gScaleX,0),petAddLeft->getContentSize()/2+ccp(30*gScaleX,0)};
	float scale[6] = {0.4*PRE_SCALE,0.4*PRE_SCALE,0.5*PRE_SCALE,0.5*PRE_SCALE,0.5*PRE_SCALE,0.5*PRE_SCALE};

	CCSprite *sp = NULL;
	if (petId != -1)
	{
		char petFile[48];
		sprintf(petFile,"ui/petUI/pet%d_0.png",petId);
		sp = CCSprite::create(petFile);
		sp->setScale(scale[petId]);
		if(leftOrRight ==0)
		{
			sp->setPosition(leftPoint[petId]);
			m_leftPitId = petId;
		}
		else
		{
			sp->setPosition(leftPoint[petId]);
			m_rightPetId  =petId;
		}

		showHeroPet(leftOrRight,petId);
	}
	else
	{
		sp = CCSprite::create("ui/shared/plus.png");	
		sp->setPosition(petAddLeft->getContentSize()/2+ccp(20*gScaleX,0));

		if(leftOrRight ==0)
		{
			if(this->getChildByTag(45456)!=NULL)
			{
				this->getChildByTag(45456)->setVisible(false);
			}
		}
		else
		{
			if(this->getChildByTag(45457)!=NULL)
			{
				this->getChildByTag(45457)->setVisible(false);
			}
		}
	}

	petAddLeft->addChild(sp,1,1000);
}
Ejemplo n.º 14
0
// on "init" you need to initialize your instance
bool HelloWorld::init()
{   
	if ( !CCLayer::init() )
    {
        return false;
    }

	CCLog(" HelloWorld  init --->");

	/*CCLog(" SCALE_FACTOR --->%f " , SCALE_FACTOR);*/

	top_distance = SCALE_FACTOR * 16;


    /*CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
 
    pCloseItem->setPosition(ccpAdd(VisibleRect::rightBottom(), 
                                ccp(-pCloseItem->getContentSize().width/2, pCloseItem->getContentSize().height/2)));
 
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);*/
 
    CCLabelTTF* pLabel = CCLabelTTF::create("hello cocos2d-x", "Arial", SCALE_FACTOR * 36 );
    pLabel->setPosition(ccpAdd(VisibleRect::top(),ccp(0, -pLabel->getContentSize().height)));
    this->addChild(pLabel, 1);
 
	//载入主菜单的pic list
	CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
    cache->addSpriteFramesWithFile("main_menu.plist", "main_menu.png");


	//背景图片
    CCSprite* pSprite = CCSprite::create("bg.jpg");
    pSprite->setPosition(VisibleRect::center());
    this->addChild(pSprite, 0);
	
	//两片树叶
	//树叶1
	CCSprite* pSprite_leaf1 = CCSprite::createWithSpriteFrameName("leaf1.png");
	pSprite_leaf1->setPosition( ccpAdd(VisibleRect::center(), ccp(0,pSprite_leaf1->getContentSize().height/2*3)) );
	this->addChild(pSprite_leaf1);

	pSprite_leaf1->setAnchorPoint(ccp(0.5f,0.0f)); //设置锚点为中下点

	//不停摆动的动画
	CCActionInterval* rotateAction1 = CCRotateBy::create(0.1f,25.0f);
    CCActionInterval* rotateAction2 = CCRotateTo::create(0.1f, -25.0f);
	CCDelayTime* sleep_rotate = CCDelayTime::create(4.0f);

	pSprite_leaf1->runAction(CCRepeatForever::create((CCActionInterval*)(CCSequence::create(rotateAction1, rotateAction2,rotateAction1, rotateAction2,sleep_rotate, NULL))));

	//树叶2
	CCSprite* pSprite_leaf2 = CCSprite::createWithSpriteFrameName("leaf2.png");
	pSprite_leaf2->setPosition( ccpAdd(VisibleRect::center(), ccp(pSprite_leaf1->getContentSize().width,pSprite_leaf1->getContentSize().height/2*3)) );
	this->addChild(pSprite_leaf2);
	pSprite_leaf2->setAnchorPoint(ccp(0.5f,0.0f)); //设置锚点为中下点


	CCDelayTime* sleep_rotate_2 = CCDelayTime::create(2.0f);
	
	pSprite_leaf2->runAction(CCRepeatForever::create((CCActionInterval*)(CCSequence::create(sleep_rotate_2,rotateAction1, rotateAction2,rotateAction1, rotateAction2,sleep_rotate_2, NULL))));


	//小岛
	CCSprite* pSprite_Island = CCSprite::create("island.png");
    pSprite_Island->setPosition(VisibleRect::center());
    this->addChild(pSprite_Island, 0);



	//设置选项(左)
	CCMenuItemSprite* pMenuItemSprite_small_left = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("small_item_normal.png"), CCSprite::createWithSpriteFrameName("small_item_pressed.png") , this, menu_selector(HelloWorld::menuCallback));   
	
	CCMenu* pSpriteMenu_small_left = CCMenu::create(pMenuItemSprite_small_left,NULL);
	pSpriteMenu_small_left->setPosition( ccpAdd(VisibleRect::center(),ccp( - pSprite_Island->getContentSize().width / 2   ,- pSprite_Island->getContentSize().height/3)) );  
	this->addChild(pSpriteMenu_small_left ,1);

	
	//帮助选项(右)
	CCMenuItemSprite* pMenuItemSprite_small_right = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("small_item_normal.png"), CCSprite::createWithSpriteFrameName("small_item_pressed.png") , this,menu_selector(HelloWorld::menuCallback));   
	
	CCMenu* pSpriteMenu_small_right = CCMenu::create(pMenuItemSprite_small_right,NULL);
	pSpriteMenu_small_right->setPosition( ccpAdd(VisibleRect::center(),ccp(  pSprite_Island->getContentSize().width / 2   ,- pSprite_Island->getContentSize().height/3)) );  
	this->addChild(pSpriteMenu_small_right ,1);


	//开始游戏选项

	CCMenuItemSprite* pMenuItemSprite = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("start_normal.png"),  CCSprite::createWithSpriteFrameName("start_pressed.png"), this,menu_selector(HelloWorld::menuCallback));   
	pMenuItemSprite->setTag(MENU_ID_START);
	
	CCMenu* pSpriteMenu = CCMenu::create(pMenuItemSprite,NULL);    
	pSpriteMenu->setPosition( ccpAdd(VisibleRect::bottom(),ccp(0,pMenuItemSprite->getContentSize().height/2*3)) );   
	this->addChild(pSpriteMenu ,1); 


	//关于我们选项
	CCMenuItemSprite* pMenuItemSprite_about = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("about_us_normal.png"), CCSprite::createWithSpriteFrameName("about_us_pressed.png"), this,menu_selector(HelloWorld::menuCallback));   
	pMenuItemSprite_about->setTag(MENU_ID_ABOUT);

	CCMenu* pSpriteMenu_about = CCMenu::create(pMenuItemSprite_about,NULL);    
	pSpriteMenu_about->setPosition( ccpAdd(pSpriteMenu->getPosition(),ccp(- (pMenuItemSprite_about->getContentSize().width+(36*SCALE_FACTOR)),0 )) );   
	this->addChild(pSpriteMenu_about ,1); 


	//左上角心跳选项
	CCMenuItemSprite* pMenuItemSprite_heart = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("heart_normal.png"), CCSprite::createWithSpriteFrameName("heart_pressed.png") , this,menu_selector(HelloWorld::menuCallback));   
	
	CCMenu* pSpriteMenu_heart = CCMenu::create(pMenuItemSprite_heart,NULL);
	pSpriteMenu_heart->setPosition( ccpAdd(VisibleRect::leftTop(),ccp(pMenuItemSprite_heart->getContentSize().width / 2 + top_distance  , -pMenuItemSprite_heart->getContentSize().height / 2 - top_distance)) );  
	this->addChild(pSpriteMenu_heart ,1);

	//添加跳动的动画效果
	CCActionInterval* scaleAction1 = CCScaleTo::create(0.1f, 1.2f, 1.2f);
    CCActionInterval* scaleAction2 = CCScaleTo::create(0.1f, 1.0f, 1.0f);
	CCDelayTime* sleep = CCDelayTime::create(1.0f);

	CCActionInterval* seq = (CCActionInterval*)(CCSequence::create(scaleAction1, scaleAction2,scaleAction1, scaleAction2,sleep, NULL));
	CCActionInterval* rep = CCRepeatForever::create(seq);

	pMenuItemSprite_heart->runAction(rep);


	//小飞块 
	CCSprite* pS_fly = CCSprite::createWithSpriteFrameName("fly.png");
	pS_fly->setPosition( ccpAdd( pSpriteMenu_heart->getPosition() , ccp(pS_fly->getContentSize().width, -pS_fly->getContentSize().height*2) ) );

	this->addChild(pS_fly);

	//添加上下来回移动的动画效果
	CCMoveBy *move = CCMoveBy::create(3.5f,ccp(0,pS_fly->getContentSize().height));  
    pS_fly->runAction(CCRepeatForever::create(static_cast<CCSequence *>(CCSequence::create(move,move->reverse(),NULL))));  


    return true;
}
Ejemplo n.º 15
0
KDbool CScrGame::init ( KDvoid )
{    
	if ( !CCLayer::init ( ) )
	{
		return KD_FALSE;
	}
    
	const CCSize&  tWinSize = CCDirector::sharedDirector ( )->getWinSize ( );

    m_uiDamaged = g_pResMgr->getSprite ( this, eIMG_Effect_Damaged );
    m_uiDamaged->setPosition ( ccpMid ( tWinSize ) );
    m_uiDamaged->setVisible ( KD_FALSE );
       
    m_uiEmergency = g_pResMgr->getSprite ( this, eIMG_Effect_Low_HP );
    m_uiEmergency->setPosition ( ccpMid ( tWinSize ) );
    m_uiEmergency->setVisible ( KD_FALSE );
    
    m_uiLayer = CCLayer::create ( );
    this->addChild ( m_uiLayer );
    
    m_uiEnergy = g_pResMgr->getProgress ( m_uiLayer, eIMG_Player_HP_Red );
    {
        const CCSize&  tSize = m_uiEnergy->getContentSize ( );
        
        m_uiEnergy->setPosition ( ccp ( tWinSize.cx - tSize.cx - 20, tWinSize.cy - tSize.cy / 2 - 20 ) );        
        m_uiEnergy->setAnchorPoint ( ccp ( 0, 0.5f ) );
        m_uiEnergy->setType ( kCCProgressTimerTypeBar );
        m_uiEnergy->setMidpoint ( ccp ( 1, 0 ) );
        m_uiEnergy->setBarChangeRate ( ccp ( 1, 0 ) );
        m_uiEnergy->setPercentage ( 100 );  
        
        CCLabelBMFont*  uiLabel = g_pResMgr->getLabel ( m_uiEnergy, "H" );        
        uiLabel->setPosition ( ccp ( -uiLabel->getContentSize ( ).cx / 2 - 10, tSize.cy / 2 ) );
    }
    
    m_uiScore = g_pResMgr->getLabel ( m_uiLayer, "Score : 0" );
    m_uiScore->setPosition ( ccp ( tWinSize.cx / 2 - 30, tWinSize.cy - m_uiScore->getContentSize ( ).cy ) );
    
    m_uiMode  = g_pResMgr->getLabel ( m_uiLayer, "Touch Mode " );
    m_uiMode->setAnchorPoint ( ccp ( 0, 0.5f ) );
    m_uiMode->setPosition ( ccp ( 150, tWinSize.cy - m_uiScore->getContentSize ( ).cy ) );
    
    m_uiRader = g_pResMgr->getSprite ( m_uiLayer, eIMG_BTN_Pad_BG );
    {
        const CCSize&  tSize = m_uiRader->getContentSize ( );
        
        m_uiRader->setPosition ( ccp ( tSize.cx / 2 + 20 , tWinSize.cy - tSize.cy / 2 - 90 ) );
    }
    
    m_uiWeapon = g_pResMgr->getSprite ( m_uiLayer, eIMG_Icon_Weapons, 0 );
    {
        const CCSize&  tSize = m_uiWeapon->getContentSize ( );
        
        m_uiWeapon->setPosition ( ccp ( tWinSize.cx - tSize.cx / 2 - 20 , tWinSize.cy - tSize.cy / 2 - 60 ) );
    }
    
	CCMenuItemSprite*  pPause = g_pResMgr->getMenuItemSprite
    (
        m_uiLayer, eIMG_BTN_Pause_Nor, ePath_Null, this, menu_selector ( CScrGame::onPause )
    );
    {
        const CCSize&  tSize = pPause->getContentSize ( );
        
        pPause->setPosition ( ccp ( tSize.cx / 2 + 20, tWinSize.cy - tSize.cy / 2 - 20 ) );    
    }
    
	CCMenuItemSprite*  pMode = g_pResMgr->getMenuItemSprite
    (
        m_uiLayer, eIMG_BTN_Pause_Nor, ePath_Null, this, menu_selector ( CScrGame::onMode )
    );
    {
        const CCSize&  tSize = pMode->getContentSize ( );
        
        pMode->setPosition ( ccp ( tSize.cx / 2 + 90, tWinSize.cy - tSize.cy / 2 - 20 ) );    
    }
    
    for ( KDuint i = 0; i < 2; i++ )
    {
        CCSprite*  uiBullet = g_pResMgr->getSprite ( m_uiLayer, eIMG_Bullet );
        {
            const CCSize&  tSize = uiBullet->getContentSize ( );
            
            uiBullet->setPosition ( ccp ( tWinSize.cx - tSize.cx / 2 - 20 , tWinSize.cy - tSize.cy / 2 - ( i == 0 ? 150 : 190 ) ) );        
            
            m_uiBulletNum[i] = g_pResMgr->getLabel ( uiBullet, "  6 x" );        
            m_uiBulletNum[i]->setPosition ( ccp ( - tSize.cx / 2, tSize.cy / 2 ) );
        }
        
        m_uiTarget[i][0] = g_pResMgr->getSprite( m_uiLayer, eIMG_Target_Out );
        m_uiTarget[i][1] = g_pResMgr->getSprite( m_uiTarget[i][0], eIMG_Target_In );        
        m_uiTarget[i][0]->setPosition ( ccp ( tWinSize.cx / 2 + ( i == 0 ? -10 : 10 ), tWinSize.cy / 2 ) );
        m_uiTarget[i][1]->setPosition ( ccpMid ( m_uiTarget[i][0]->getContentSize ( ) ) );      
        m_uiTarget[i][1]->setVisible ( KD_FALSE );
        
        m_uiPad[i][0] = g_pResMgr->getSprite ( this, eIMG_BTN_Pad_BG );
        m_uiPad[i][1] = g_pResMgr->getSprite ( m_uiPad[i][0], eIMG_BTN_Pad_Nor );
        m_uiPad[i][2] = g_pResMgr->getSprite ( m_uiPad[i][0], eIMG_BTN_Pad_Sel );
        {
            const CCSize&  tSize = m_uiPad[i][0]->getContentSize ( );
            
            m_uiPad[i][0]->setPosition ( ccp ( i == 0 ? tSize.cx / 2 + 20 : tWinSize.cx - tSize.cx / 2 - 20, tSize.cy / 2 + 20 ) );
            m_uiPad[i][1]->setPosition ( ccpMid ( tSize ) );
            m_uiPad[i][2]->setPosition ( ccpMid ( tSize ) );
            m_uiPad[i][1]->setTag ( i );
            m_uiPad[i][2]->setVisible ( KD_FALSE );
        }        
        
        CCMenuItemSprite*  uiReload = g_pResMgr->getMenuItemSprite
        (
            m_uiLayer, eIMG_BTN_Reload_Nor, ePath_Null, this, menu_selector ( CScrGame::onReload )
        );        
        {
            const CCSize&  tSize = uiReload->getContentSize ( );
            
            uiReload->setPosition ( ccp ( i == 0 ? tSize.cx / 2 + 20 : tWinSize.cx - tSize.cx / 2 - 20, tSize.cy / 2 + 160 ) );
            uiReload->setTag ( i );            
        }
    }
    
    CCMenuItemSprite*  uiChange = g_pResMgr->getMenuItemSprite
    (
        m_uiLayer, eIMG_BTN_Change_Nor, ePath_Null, this, menu_selector ( CScrGame::onChange )
    );        
    {
        const CCSize&  tSize = uiChange->getContentSize ( );
        
        uiChange->setPosition ( ccp ( tWinSize.cx - tSize.cx / 2 - 160, tSize.cy / 2 + 20 ) );
    }    
    
    // Clear Scene
    g_pEngMgr->getScene ( )->clear ( );
    g_pEngMgr->getTimer ( )->stop  ( );
    
    // Create World
    m_pWorld    = new CWorld   ( );
    m_pWeapon   = new CWeapon  ( );
    m_pTarget   = new CTarget  ( );
    m_pBullet   = new CBullet  ( );
    m_pEnemies  = new CEnemies ( );
    
    m_pWorld  ->init ( );
    m_pWeapon ->init ( );
    m_pTarget ->init ( m_pWorld->getNode ( ) );
    m_pEnemies->init ( m_pWorld->getPosition ( ), m_pWorld->getSpawnDist ( ), m_uiRader );
    
    g_pResMgr->getSound ( eSND_Effect_Heart );
    g_pResMgr->getSound ( eSND_Player_Harm );
    g_pResMgr->getSound ( eSND_Player_Dead );
    
    this->setTouchMode ( kCCTouchesOneByOne );
    this->setTouchEnabled ( KD_TRUE );
    this->setEventEnabled ( KD_TRUE );
    this->setClipping     ( KD_TRUE );
    
    m_bUseSensor   = KD_FALSE;    
    m_bTargetCtl   = KD_FALSE;
    m_uWeaponIndex = 0;
    
    g_pEnvMgr->setScore ( 0 );
    g_pEnvMgr->setEnergy ( 100 );
    
    for ( KDint i = 0; i < 2; i++ )
    {
        m_uBulletNum[i][0] = m_uBulletNum[i][1] = m_pWeapon->getBulletNum ( i );
    }
    
    refreshBulletLabel ( 0 );
    refreshBulletLabel ( 1 );
    
	return KD_TRUE;
}
Ejemplo n.º 16
0
void LevelMap::adjustMap(bool isResetLevel)
{
	int num = floor(offsetY/442);
	currentMap = -num;
	int offnum = num%3;
	float tmpoff = offsetY - num*442;
	mapLayer->setPosition(ccp(0, (offnum-1)*442 + tmpoff));

	if(isResetLevel)
	{
		int offlevel = 1000 + currentMap*3 -3;
		for (int i = 0; i < 9 ; i++)
		{
			MapItem* tmpLevelItemData = NULL;
			tmpLevelItemData = CData::getCData()->getConfigOfMapLevel(offlevel + i);

			CCMenuItemSprite* tmp = (CCMenuItemSprite*)levelSpDic->objectForKey(i);
			tmp->removeChildByTag(9999);

			if (tmpLevelItemData!= NULL && tmpLevelItemData->bid < currentLevelId)
			{
				CCSize tmpsz = tmp->getContentSize();
				CCSprite* ssp = CCSprite::create();

				int num = data["citylist"][tmpLevelItemData->bid - 1000].asInt();
				for (int k = 0; k<num; k++)
				{
					CCSprite * star = CCSprite::create("zjm_star.png");
					star->setPosition(ccp(k*30, 0));
					ssp->addChild(star);
				}
				ssp->setPosition(ccp(tmpsz.width/2-15*num+15, 0));
				ssp->setTag(9999);
				tmp->addChild(ssp, 0);
			}

			if(tmpLevelItemData != NULL)
			{
				if(tmpLevelItemData->bid > currentLevelId)
				{
					tmp->setEnabled(false);
				}
				else
				{
					tmp->setEnabled(true);
				}
				tmp->setUserObject(tmpLevelItemData);
			}

			//for (int j = 1001; j<=1005; j++)
			//{
			CCLabelTTF* tmpName = (CCLabelTTF*)(tmp->getChildByTag(1002));
			if(tmpLevelItemData)
			{
				tmpName->setString(tmpLevelItemData->nickname.c_str());
			}
			//}
		}
	}

	levelsMenu->setPosition(ccp(0, -442 + tmpoff));
}
Ejemplo n.º 17
0
bool VVAlertView::initWithTitle(const char* aTitle, const char* aMessage, VVAlertViewDelegate* aDelegate, const char* aCancelBtnTitle, const char* aOtherBtnTitle)
{
    if ( !VVPopupLayer::init() )
		return false;
    
    delegate = aDelegate;
    
    overlayLayer->removeFromParentAndCleanup(true);
    
    CCLabelTTF *titleLabel = NULL;
    
    if( aTitle != NULL )
    {
        titleLabel = CCLabelTTF ::labelWithString(aTitle ,fontName.c_str(), titleFontSize);
    }
    
    CCScale9Sprite *bg = CCScale9Sprite::scale9SpriteWithFile(alertBG_name.c_str(), alert9patch_rect);
    
    
    CCLabelTTF *msgLabel = CCLabelTTF::labelWithString(aMessage, CCSizeMake(maxWidth-borderPadding*4, 0), CCTextAlignmentCenter, fontName.c_str(), messageFontSize);
    
    
    CCMenuItemSprite* btnCancel = CCMenuItemDynamic::dynamicItemWithTTFLabel(aCancelBtnTitle, fontName.c_str(), messageFontSize, btnSize, btnBG_name.c_str(), NULL, this,
                                                                             menu_selector(VVAlertView::onBtnCancel), 
                                                                             btn9patch_rect, 255);
    CCMenu *menu;
    if (aOtherBtnTitle == NULL) 
    {
        menu = CCMenu::menuWithItems(btnCancel, NULL);
    }
    else
    {
        CCMenuItemSprite* btnOk = CCMenuItemDynamic::dynamicItemWithTTFLabel(aOtherBtnTitle, fontName.c_str(), messageFontSize, btnSize, btnBG_name.c_str(), NULL, this,
                                                                                 menu_selector(VVAlertView::onBtnOk), 
                                                                                 btn9patch_rect, 255);

        menu = CCMenu::menuWithItems(btnCancel, btnOk, NULL);
        menu->alignItemsHorizontallyWithPadding(betweenBtnPadding);
    }
     
    
    menu->setTouchPriority(VVTouchPriorityMenuOnPopupLayer);
    
    addChild(bg);
    if (titleLabel) 
        addChild(titleLabel);            

    addChild(msgLabel);    
    addChild(menu);
    
    
    if (titleLabel)     
        totalHeight += titleLabel->getContentSize().height;    
    
    totalHeight += msgLabel->getContentSize().height;    
    totalHeight += btnCancel->getContentSize().height;
    totalHeight += centerPadding;
    
    totalHeight += messagePadding*2;
    totalHeight += borderPadding*2;
    
    float halfHeight = totalHeight/2;
    
    if (titleLabel) 
    {
        titleLabel  ->setPosition(ccp(0, halfHeight - borderPadding - titleLabel->getContentSize().height/2)); // -15 : top padding
        msgLabel    ->setPosition(ccp(0, halfHeight - borderPadding - titleLabel->getContentSize().height - messagePadding - msgLabel->getContentSize().height/2 ));
    }
    else
    {
        msgLabel    ->setPosition(ccp(0, halfHeight - borderPadding - msgLabel->getContentSize().height/2 ));
    }
    menu        ->setPosition(ccp(0, -halfHeight + borderPadding + btnCancel->getContentSize().height/2));
    
    bg->setContentSize(CCSizeMake(maxWidth, totalHeight));
    
    
    // will be used for placing text field in the middle
    centerOfMargin = (msgLabel->getPosition().y + menu->getPosition().y)/2;
    
    return true;
}
Ejemplo n.º 18
0
// on "init" you need to initialize your instance
bool InGameTopMenuLayer::init() {
	if (!CCLayerColor::initWithColor(ccc4(255, 255, 255, 255)))
		return false;
	float scaleMult = Model::getInstance()->getGUIElementScaleMultiplicator();
	float button_length = 66 * scaleMult;
	float button_heigth = 66 * scaleMult;
	float padding = 10 * scaleMult;
	_soundOnString = "on";
	_soundOffString = "off";

	CCMenuItemSprite *shutdown = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("shutdown0.png"),
			CCSprite::createWithSpriteFrameName("shutdown1.png"), (CCObject*) this, menu_selector(InGameTopMenuLayer::shutdownTouched));
	shutdown->setScaleX(button_length / shutdown->getContentSize().width);
	shutdown->setScaleY(button_heigth / shutdown->getContentSize().height);

	CCMenuItemSprite *autoCam = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("autoCam0.png"),
			CCSprite::createWithSpriteFrameName("autoCam1.png"), (CCObject*) this, menu_selector(InGameTopMenuLayer::autoCamTouched));
	autoCam->setScaleX(button_length / autoCam->getContentSize().width);
	autoCam->setScaleY(button_heigth / autoCam->getContentSize().height);

	float scale = button_heigth / autoCam->getContentSize().height;
	_autCamOnOffLabel = CCLabelTTF::create("auto", FONT_NAME, PRICE_LABEL_FONT_SIZE / scale * scaleMult,
			CCSize(autoCam->getContentSize().width, PRICE_LABEL_HEIGTH / scale * scaleMult), kCCTextAlignmentCenter);
	autoCam->addChild(_autCamOnOffLabel);
	_autCamOnOffLabel->setColor(Model::getInstance()->getInGameGameLayer()->getAutoCam() ? ccc3(0, 255, 0) : ccc3(255, 0, 0));
	_autCamOnOffLabel->setPosition(CCPoint(autoCam->getContentSize().width / 2, PRICE_LABEL_BOTTOM_SPACE / scale * scaleMult));
	_autCamOnOffLabel->enableStroke(PRICE_LABEL_COLOR_STROKE, PRICE_LABEL_STROKE_SIZE / scale * scaleMult, true);

	CCMenuItemSprite *autoCamSwitch = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("autoCamSwitch0.png"),
			CCSprite::createWithSpriteFrameName("autoCamSwitch1.png"), (CCObject*) this, menu_selector(InGameTopMenuLayer::flipThisPlayerForCamTouched));
	autoCamSwitch->setScaleX(button_length / autoCamSwitch->getContentSize().width);
	autoCamSwitch->setScaleY(button_heigth / autoCamSwitch->getContentSize().height);

	CCMenuItemSprite *pause = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("pause1.png"), CCSprite::createWithSpriteFrameName("pause2.png"),
			(CCObject*) this, menu_selector(InGameTopMenuLayer::pauseTouched));
	pause->setScaleX(button_length / pause->getContentSize().width);
	pause->setScaleY(button_heigth / pause->getContentSize().height);

	CCMenuItemSprite *zoomIn = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("ZoomIn1.png"), CCSprite::createWithSpriteFrameName("ZoomIn2.png"),
			(CCObject*) this, menu_selector(InGameTopMenuLayer::zoomInTouched));
	zoomIn->setScaleX(button_length / zoomIn->getContentSize().width);
	zoomIn->setScaleY(button_heigth / zoomIn->getContentSize().height);

	CCMenuItemSprite *zoomOut = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("ZoomOut1.png"),
			CCSprite::createWithSpriteFrameName("ZoomOut2.png"), (CCObject*) this, menu_selector(InGameTopMenuLayer::zoomOutTouched));
	zoomOut->setScaleX(button_length / zoomOut->getContentSize().width);
	zoomOut->setScaleY(button_heigth / zoomOut->getContentSize().height);

	CCMenuItemSprite *toggleGUI = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("toggleGUI1.png"),
			CCSprite::createWithSpriteFrameName("toggleGUI2.png"), (CCObject*) this, menu_selector(InGameTopMenuLayer::toggleGUITouched));
	toggleGUI->setScaleX(button_length / toggleGUI->getContentSize().width);
	toggleGUI->setScaleY(button_heigth / toggleGUI->getContentSize().height);

	CCMenuItemSprite *enableSound = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("soundEnable0.png"),
			CCSprite::createWithSpriteFrameName("soundEnable1.png"), (CCObject*) this, menu_selector(InGameTopMenuLayer::enableSoundTouched));
	enableSound->setScaleX(button_length / enableSound->getContentSize().width);
	enableSound->setScaleY(button_heigth / enableSound->getContentSize().height);

	scale = button_heigth / enableSound->getContentSize().height;
	_enableSoundLabel = CCLabelTTF::create(SoundHandler::getInstance()->isSoundEnabled() ? _soundOnString.c_str() : _soundOffString.c_str(), FONT_NAME,
			PRICE_LABEL_FONT_SIZE / scale * scaleMult, CCSize(enableSound->getContentSize().width, PRICE_LABEL_HEIGTH / scale * scaleMult),
			kCCTextAlignmentCenter);
	enableSound->addChild(_enableSoundLabel);
	_enableSoundLabel->setColor(SoundHandler::getInstance()->isSoundEnabled() ? ccc3(0, 255, 0) : ccc3(255, 0, 0));
	_enableSoundLabel->setPosition(CCPoint(enableSound->getContentSize().width / 2, PRICE_LABEL_BOTTOM_SPACE / scale * scaleMult));
	_enableSoundLabel->enableStroke(PRICE_LABEL_COLOR_STROKE, PRICE_LABEL_STROKE_SIZE / scale * scaleMult, true);

	CCMenu* menu = CCMenu::create();
	int x = 0;
	int y = 1;
	ViewTools::addToMenu(menu, zoomIn, button_length, button_heigth, x++, y, padding);
	ViewTools::addToMenu(menu, zoomOut, button_length, button_heigth, x++, y, padding);
	ViewTools::addToMenu(menu, autoCamSwitch, button_length, button_heigth, x++, y, padding);
	ViewTools::addToMenu(menu, autoCam, button_length, button_heigth, x++, y, padding);
	ViewTools::addToMenu(menu, toggleGUI, button_length, button_heigth, x++, y, padding);

	if (Model::getInstance()->getGameMode() != NETWORK)
		ViewTools::addToMenu(menu, pause, button_length, button_heigth, x++, y, padding);

	ViewTools::addToMenu(menu, shutdown, button_length, button_heigth, x, y, padding);
	ViewTools::addToMenu(menu, enableSound, button_length, button_heigth, x, y - 1, padding);

	// resizing this layer to the menu and place the menu correct
	float width = (x + 1) * button_length + x * padding;

	float height = button_heigth * 2 + padding;
	setContentSize(CCSize(width, height));
	menu->setPosition(0, 0);
	addChild(menu);

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	setPosition(winSize.width - width - (UNITS_INFO_OVERLAY_WIDTH * scaleMult), winSize.height - height);
	setOpacity(0); // 0- total transparent, 255 not
	return true;
}
Ejemplo n.º 19
0
bool LevelMap::init()
{
    if(!CCLayer::init())
    {
        return false;
    }
    
    this->setTouchEnabled(true);
    
    levelSpDic = CCDictionary::create();
    levelSpDic->retain();
    
    currentMap = 0;
    size = CCDirector::sharedDirector()->getWinSize();
    
//    CCSprite* bkg = CCSprite::create("zjm_bkg.png");
//    bkg->setAnchorPoint(ccp(0, 0));
//    bkg->setPosition(ccp(0, 0));
//    this->addChild(bkg);
    
    mapLayer = CCSprite::create();
    
    CCSprite* m1 = CCSprite::create("map3.png");
    m1->setAnchorPoint(ccp(0, 0));
    m1->setPosition(ccp(0, 0));
    
    CCSprite* m2 = CCSprite::create("map1.png");
    m2->setAnchorPoint(ccp(0, 0));
    m2->setPosition(ccp(0, 441));
    
    CCSprite* m3 = CCSprite::create("map2.png");
    m3->setAnchorPoint(ccp(0, 0));
    m3->setPosition(ccp(0, 441*2));
    
    CCSprite* m4 = CCSprite::create("map3.png");
    m4->setAnchorPoint(ccp(0, 0));
    m4->setPosition(ccp(0, 441*3));
    
    CCSprite* m5 = CCSprite::create("map1.png");
    m5->setAnchorPoint(ccp(0, 0));
    m5->setPosition(ccp(0, 441*4));
   
    mapLayer->addChild(m1);
    mapLayer->addChild(m2);
    mapLayer->addChild(m3);
    mapLayer->addChild(m4);
    mapLayer->addChild(m5);
    mapLayer->setAnchorPoint(ccp(0, 0));
    mapLayer->setPosition(ccp(0, 0));
    
	// 将一个Layer添加到CCSprite里面
    mapSp = CCSprite::create();
    mapSp->addChild(mapLayer);
    mapSp->setAnchorPoint(ccp(0, 0));
    mapSp->setPosition(ccp(0, 0));
    this->addChild(mapSp);
    
    levelsMenu = CCMenu::create();
    levelsMenu->setAnchorPoint(ccp(0, 0));
    levelsMenu->setPosition(ccp(0, 0));
    this->addChild(levelsMenu);
    
    CCSprite* bkg = CCSprite::create("zjm_bkg.png");
    bkg->setAnchorPoint(ccp(0, 0));
    bkg->setPosition(ccp(0, 0));
    this->addChild(bkg);
    
    for (int i = 0; i < 9; i++)
    {
		// 地图上的选中框,并添加点击事件clkBuilding;
        CCMenuItemSprite* leveltmp = CCMenuItemImage::create("zjm_building_1.png", "zjm_building_1.png", "zjm_building_2.png",this, menu_selector(LevelMap::clkBuilding));
        int num = (int)floor((float)i/3);
        
        leveltmp->setPosition(ccp((i-3*num)%2==1?140:size.width-130, (130)*(i%3) + 442*(int)floor((float)i/3) +240));//160
        levelSpDic->setObject(leveltmp, i);
        levelsMenu->addChild(leveltmp);
        
        const ccColor3B color3 = {255,175,100};
        const ccColor3B colorbg = {255,175,51};
        
        CCSize tmpsz = leveltmp->getContentSize();
        CCLabelTTF * name11=CCLabelTTF::create("", "hycc.ttf", 20);
        name11->setDimensions(CCSizeMake(200, 0));
        name11->setHorizontalAlignment(kCCTextAlignmentCenter);
        name11->setVerticalAlignment(kCCVerticalTextAlignmentTop);
        name11->setPosition(ccp(tmpsz.width/2-1, 35));
        
        name11->setColor(colorbg);
//        leveltmp->addChild(name11);
        leveltmp->addChild(name11, 10);
        name11->setTag(1002);
    }
    
    char * json=CData::getCData()->cityData;
    Json::Reader read;
    Json::Value  root;
    
    if(read.parse(json, root))
    {
        data=root["data"];
    }

    currentLevelId = data["cityid"].asInt();
    if (CData::getCData()->levelMapOffsetY > 0)
    {
        offsetY = -((int)ceil(((float)currentLevelId-1000)/3))*442;
        //size.height;
    }
    else
    {
        offsetY = CData::getCData()->levelMapOffsetY;
    }
    
    //    offsetY = 0;
    mapNum = CData::getCData()->getLevelMapNum();
    
    adjustMap(true);
    return true;
}