void E002_Base_P420_CompletePopup::setButtions()
{
    CJSprite* reworkBtnN = CJSprite::createWithCommonPath("e002_common_diary_btn_rework_n.png");
    CJSprite* reworkBtnS = CJSprite::createWithCommonPath("e002_common_diary_btn_rework_s.png");

    CCMenuItemSprite*  reworkBtn = CCMenuItemSprite::create(reworkBtnN,
                                                           reworkBtnS,
                                                           this,
                                                            menu_selector(E002_Base_P420_CompletePopup::_onTouchedReworkBtn));
    
    reworkBtn->setPosition(CJPsdParser::getPsdPosition("e002_common_diary_btn_rework_n", m_psdDictionary));
    
    CJSprite* finishBtnN = CJSprite::createWithCommonPath("e002_common_diary_btn_finish_n.png");
    CJSprite* finishBtnS = CJSprite::createWithCommonPath("e002_common_diary_btn_finish_s.png");
    
    CCMenuItemSprite*  finishBtn = CCMenuItemSprite::create(finishBtnN,
                                                          finishBtnS,
                                                          this,
                                                          menu_selector(E002_Base_P420_CompletePopup::_onTouchedFinishBtn));
    
    finishBtn->setPosition(CJPsdParser::getPsdPosition("e002_common_diary_btn_finish_n", m_psdDictionary));
    
    
   

    CCMenu *menu = CCMenu::create(reworkBtn, finishBtn, NULL);

    menu->setPosition(CCPointZero);
    addChild(menu, kDepth1_actors);

}
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;
}
Beispiel #3
0
void PrepareLayer::showBuyCoin()
{
	CCSize size = ToolsFun::sharedTools()->getSceneSize();
	CCSprite *bkg = CCSprite::create("DayReward/bkg.png");
	this->addChild(bkg,200,12313154);
	bkg->setPosition(ccp(size.width/2,size.height/2));

	CCSprite *tip1 = CCSprite::create("DayReward/50000coin.png");
	bkg->addChild(tip1);
	tip1->setPosition(ccp(bkg->getContentSize().width/2,bkg->getContentSize().height/2-50*gScaleY));

	CCMenu *menu = CCMenu::create();
	bkg->addChild(menu);
	menu->setPosition(CCPointZero);

	CCSprite *closeNml = CCSprite::create("ui/backUI/close0.png");
	CCSprite *closeSel = CCSprite::create("ui/backUI/close0.png");
	closeSel->setColor(ccc3(80,80,80));

	CCMenuItemSprite *itemClose = CCMenuItemSprite::create(closeNml,closeSel,NULL,this,menu_selector(PrepareLayer::showBuyCoinClose));

	itemClose->setPosition(ccp(bkg->getContentSize().width-40*gScaleX ,bkg->getContentSize().height-60*gScaleY));
	menu->addChild(itemClose);

	CCSprite *spNml = CCSprite::create("DayReward/button.png");
	CCSprite *spSel = CCSprite::create("DayReward/button.png");
	spSel->setColor(ccc3(80,80,80));
	CCMenuItemSprite *itemSp = CCMenuItemSprite::create(spNml,spSel,this,menu_selector(PrepareLayer::showBuyCoinSure));
	itemSp->setPosition(ccp(bkg->getContentSize().width/2 ,35*gScaleY));
	menu->addChild(itemSp);
}
void FairyControlPanel::initButton(){
	controlType = 1;
	panelBack->removeAllChildrenWithCleanup(true);
	CCSize size = panelBack->getContentSize();
	CCSprite* leftNormal = CCSprite::create(uiLeftNormal);
	CCSprite* leftClick = CCSprite::create(uiLeftClick);
	CCSprite* holdNormal = CCSprite::create(uiHoldNormal);
	CCSprite* holdClick = CCSprite::create(uiHoldClick);
	CCSprite* rightNormal = CCSprite::create(uiRightNormal);
	CCSprite* rightClick = CCSprite::create(uiRightClick);
	CCSprite* upNormal = CCSprite::create(uiUpNormal);
	CCSprite* upClick = CCSprite::create(uiUpClick);
	CCMenuItemSprite* leftButton = CCMenuItemSprite::create(leftNormal, leftClick, this, menu_selector(FairyControlPanel::fairyMenuCallback));
	leftButton->setTag(leftDrection);
	CCMenuItemSprite* holdButton = CCMenuItemSprite::create(holdNormal, holdClick, this, menu_selector(FairyControlPanel::fairyMenuCallback));
	holdButton->setTag(holdDrection);
	CCMenuItemSprite* rightButton = CCMenuItemSprite::create(rightNormal, rightClick, this, menu_selector(FairyControlPanel::fairyMenuCallback));
	rightButton->setTag(rightDrection);
	CCMenuItemSprite* upButton = CCMenuItemSprite::create(upNormal, upClick, this, menu_selector(FairyControlPanel::fairyMenuCallback));
	upButton->setTag(upDrection);
	CCMenu* menu = CCMenu::create(leftButton, holdButton, rightButton, upButton, NULL);
	leftButton->setPosition(ccp(size.width / 5, size.height / 2 + 30));
	upButton->setPosition(ccp(2 * size.width / 5, size.height / 2+ 30));
	holdButton->setPosition(ccp(3 * size.width / 5, size.height / 2 + 30));
	rightButton->setPosition(ccp(4 * size.width / 5, size.height / 2 + 30));
	panelBack->addChild(menu);
	menu->setPosition(ccp(0, - 30));
}
Beispiel #5
0
bool CStoreLayer::init()
{
	if ( !CCLayer::init() )
		return false;

	CCLayerColor*	player = CCLayerColor::create(ccc4( 0, 0, 0, 50));
	this->addChild(player);

	CCSize size = CCDirector::sharedDirector()->getWinSize();

	CCTextureCache::sharedTextureCache()->addImage(CONS_DefaultStoreBackGround);

 	CCSprite* pSprite = CCSprite::create( CONS_DefaultStoreBackGround );
 	pSprite->setPosition( ccp( size.width/2, size.height/2 ) );
 	this->addChild( pSprite );

	CCSize sPSize = this->getContentSize();

	CCSprite * ci1 = CCSprite::createWithSpriteFrameName(CONS_Image_Menu_Cancel);
	CCSprite * ci12 = CCSprite::createWithSpriteFrameName(CONS_Image_Menu_Cancel_2);

	CCMenuItemSprite* pCancel = CCMenuItemSprite::create(ci1,ci12,NULL,this,
		menu_selector(CStoreLayer::CanleCallback));
	pCancel->setPosition( ccp(size.width*0.9,size.height*0.1) ); 
	pCancel->setTag( CANLETAG );

	CCSprite* ci3 = CCSprite::create( "Image/Menu_new/TowRMB.png" );
	CCSprite* ci4 = CCSprite::create( "Image/Menu_new/FourRMB.png" );
	CCSprite* ci5 = CCSprite::create( "Image/Menu_new/SixRMB.png" );

	CCMenuItemSprite* pTow = CCMenuItemSprite::create(ci3,ci3,NULL,this,
		menu_selector(CStoreLayer::CanleCallback));
	pTow->setPosition( ccp(sPSize.width / 2, sPSize.height * 0.7 ) ); 
	pTow->setTag( TOWRMBTAG );

	CCMenuItemSprite* pFour = CCMenuItemSprite::create(ci4,ci4,NULL,this,
		menu_selector(CStoreLayer::CanleCallback));
	pFour->setPosition( ccp(sPSize.width/ 2, sPSize.height * 0.5 ) ); 
	pFour->setTag( FOURRMBTAG );

	CCMenuItemSprite* pSix = CCMenuItemSprite::create(ci5,ci5,NULL,this,
		menu_selector(CStoreLayer::CanleCallback));
	pSix->setPosition( ccp(sPSize.width / 2, sPSize.height * 0.3) ); 
	pSix->setTag( SIXRMBTAG );

	CCMenu* pMenu = CCMenu::create( pCancel, pTow, pFour, pSix, NULL );
	pMenu->setPosition(CCPointZero);
	this->addChild(pMenu, 999);		

	this->setTouchEnabled( true );

	AppDelegate::cur_scene_flag = shop_layer;
	AppDelegate::g_pLayer = this;

	return true;
}
Beispiel #6
0
bool Scene1Welcome::init(){
	
	if(!CCScene::init()){
		return false;
	}
	
	CCSize size = CCDirector::sharedDirector()->getWinSize();
	
	CCSprite* pBg = CCSprite::create("*****@*****.**");
	pBg->setPosition(ccp(size.width/2, size.height/2));
	
	CCLayer* layerBtns = CCLayer::create();
	
	this->addChild(pBg);
	this->addChild(layerBtns);
	
	CCSprite* pLogo = CCSprite::create("logo.png");
	pLogo->setAnchorPoint(ccp(0.5, 1));
	pLogo->setPosition(ccp(size.width/2, size.height-150));
	layerBtns->addChild(pLogo);
	
	
	CCSprite* spriteBtnPlay = CCSprite::create("btn_play.png");
	CCSprite* spriteBtnPlaySelected = CCSprite::create("btn_play_selected.png");
	CCMenuItemSprite* menuBtnPlay = CCMenuItemSprite::create(spriteBtnPlay,
															 spriteBtnPlaySelected,
															 this,
															 menu_selector(Scene1Welcome::onBtnPlayClick));
	menuBtnPlay->setPosition(ccp(0.5, 1));
	menuBtnPlay->setPosition(ccp(size.width/2, size.height-420));
	//CCLog("%f", size.height);
	
	MainMenu* mainMenu = new MainMenu();
	
	//layerBtns->addChild(pBtnPlay);
	//layerBtns->addChild(spriteBtnMain);
	
	
	CCMenu* pMenu = CCMenu::create(menuBtnPlay, NULL);
	pMenu->setPosition(CCPointZero);
	layerBtns->addChild(pMenu);
	//layerBtns->addChild(mainMenu->pMenu);
	//mainMenu->showWithAnimate();
	
	//CCActionInterval* actionInterval = CCActionInterval::create(5);
	//CCEaseBackInOut* easeBackInOut = CCEaseBackInOut::create(actionInterval);
	
	//pLogo->runAction(easeBackInOut);
	
	return true;
}
Beispiel #7
0
void HomeScene::__initMainMenu()
{
    CCMenuItemSprite *classic = BaseMenuItemSprite::create(SPRITE("*****@*****.**"),SPRITE("*****@*****.**"),this,menu_selector(HomeScene::__gotoClassic));
    CCMenuItemSprite *icebreak = BaseMenuItemSprite::create(SPRITE("*****@*****.**"),SPRITE("*****@*****.**"),this,menu_selector(HomeScene::__gotoIcebreak));
    CCMenuItemSprite *pandora = BaseMenuItemSprite::create(SPRITE("*****@*****.**"),SPRITE("*****@*****.**"),this,menu_selector(HomeScene::__gotoPandora));
    CCMenuItemSprite *setting = BaseMenuItemSprite::create(SPRITE("*****@*****.**"),SPRITE("*****@*****.**"),this,menu_selector(HomeScene::__gotoSettingScene));
	CCMenuItemSprite *rank = BaseMenuItemSprite::create(SPRITE("*****@*****.**"),SPRITE("*****@*****.**"),this,NULL);
	CCMenu *mainMenu = CCMenu::create(classic,setting,NULL);
    addChild(mainMenu);
	rank->setPosition(ccp(-130,-365));
	setting->setPosition(ccp(-250,-365));
	classic->setPosition(ccp(0,130));
	pandora->setPosition(ccp(0,-130));
}
Beispiel #8
0
void NewsScene::createListView()
{
//    CCSize size = CCSize(750, 400);
    CCSize size = CCDirector::sharedDirector()->getWinSize();
  
    CCLayerColor * fundo =  CCLayerColor::create(ccc4(255, 255, 255, 255), size.width, size.height);
    fundo->setAnchorPoint(ccp(0,0));
    fundo->setPosition(ccp(0, 0));
    this->addChild(fundo,10);
//    CCLayerColor * header =  CCLayerColor::create(ccc4(200, 200, 200, 255), size.width, 80);
//    header->setAnchorPoint(ccp(0,0));
//    header->setPosition(ccp(0, size.height -80));
//    fundo->addChild(header);
    
    CCSprite *sprHeader;
    sprHeader = CCSprite::create("Header_Blue.png");
    
    sprHeader->setAnchorPoint(ccp(0,0));
    sprHeader->setScale(1);
    sprHeader->setPosition(ccp(0, size.height -90));
    this->addChild(sprHeader,100);
    CCSprite *sprTitle;
    sprTitle = CCSprite::create("tit_informacoes.png");
    
    sprTitle->setAnchorPoint(ccp(0,0));
    sprTitle->setScale(1);
    sprTitle->setPosition(ccp(110, size.height -50));
    this->addChild(sprTitle,101);
    
    CCMenu* menu = CCMenu::create();
    
    CCSprite *spriteDefault = CCSprite::create("Seta1.png");
    CCSprite *spriteSelected = CCSprite::create("Seta2.png");
    CCMenuItemSprite *item = CCMenuItemSprite::create(spriteDefault, spriteSelected, this,  menu_selector(NewsScene::btnBack));
    item->setAnchorPoint(ccp(0, 0));
    item->setPosition(ccp(0, size.height -90));
    menu->addChild(item, 0, 100);
    menu->setPosition(ccp(10,30));
    menu->setAnchorPoint(ccp(0,0));
    this->addChild(menu,102);
    
    list = CCListView::create(CCListViewModeVertical);
    list = cocos2d::extension::CCListView::create(CCListViewModeVertical);
    list->setDelegate(this);
    list->setContentSize(CCSize(size.width, size.height-70));
    list->setAnchorPoint(ccp(0,0));
    list->setPosition(ccp(0, 0));
    list->setColor(ccc3(50, 50, 50));
    list->setSeparatorStyle(CCListViewCellSeparatorStyleNone);
    
    fundo->addChild(list);
    this->loading = new AnimatedSprite("loader_einstein1.png");
	this->loading->addAnimation(AnimatedSprite::animationWithFile("loader_einstein", 24, 0.030f), "anim");//frame_count
    
    this->addChild(this->loading,999);
    this->loading->runAnimation("anim",true, true);
	this->loading->setAnchorPoint(ccp(0.5f, 0.5f));
	this->loading->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width/2, CCDirector::sharedDirector()->getWinSize().height/2 - 30));
    this->loading->setVisible(true);
}
Beispiel #9
0
void SlidingMenuGrid::buildGrid(int cols, int rows)
{
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
	int col = 0, row = 0;
	CCArray* child = pMenu->getChildren();
	CCObject* item;
	CCPoint position=getPosition();
	iPageCount=0;
	CCARRAY_FOREACH(child, item)
	{
		CCMenuItemSprite* getItem = (CCMenuItemSprite*) item;
		getItem->setPosition(ccp(position.x +  menuOrigin.x + col * padding.x + (iPageCount * winSize.width), position.y +(winSize.height-menuOrigin.y)- row * padding.y));
		++col;
		if (col == cols)
		{
			col = 0;
			++row;
			if( row == rows )
			{
				iPageCount++;
				col = 0;
				row = 0;
			}
		}
        
	}
Beispiel #10
0
void RankScene::BasicUIDraw(){
    
    //1.背景
    CCSprite* bg = CCSprite::createWithSpriteFrameName("bg_l.png");
    bg->setPosition(ccp(winSize.width/2, winSize.height/2));
    addChild(bg,0);
    
    //2.翻转层
    layerToRoll = CCLayer::create();
    addChild(layerToRoll,1);
    
    //3.金币部分
    CCSprite* heartTable = CCSprite::createWithSpriteFrameName("HeartTable.png");
    heartTable->setScaleX(0.5);
    heartTable->setScaleY(0.417);
    heartTable->setPosition(ccp(size.width*7.75/30,size.height*2100/2200+winDif*4*(2-alpha)));
    addChild(heartTable,9999);
    
    CCSprite* goldTable = CCSprite::createWithSpriteFrameName("GoldTable.png");
    goldTable->setScale(0.417);
    goldTable->setPosition(ccp(size.width*21.75/30,size.height*2100/2200+winDif*4*(2-alpha)));
    addChild(goldTable,9999);
    
    CCLabelTTF* goldNumber = CCLabelTTF::create(int2string(MainUser->gold).c_str(), "Arial Rounded MT bold",28,CCSizeMake(size.width/3, 0),kCCTextAlignmentRight);
    goldNumber->setPosition(ccp(size.width*45.5/70, size.height*2100/2200+winDif*4*(2-alpha)));
    addChild(goldNumber,10000,8);
    
    CCSprite* buyGoldButtonSprite = CCSprite::createWithSpriteFrameName("buyGoldButton.png");
    CCSprite* buyGoldButtonSprite_s = CCSprite::createWithSpriteFrameName("buyGoldButton-s.png");
    CCMenuItemSprite* buyGoldButton = CCMenuItemSprite::create(buyGoldButtonSprite,buyGoldButtonSprite_s,this,menu_selector(RankScene::showShopLayer));
    buyGoldButton->setPosition(ccp(size.width*60/70,size.height*2100/2200+winDif*4*(2-alpha)));
    CCMenu* buyGoldMenu = CCMenu::create(buyGoldButton,NULL);
    buyGoldMenu->setPosition(CCPointZero);
    addChild(buyGoldMenu,10000,17);
}
void GameScene::touchPauseCallBack(CCObject* obj) {
    if (isGameOver) {
        return;
    }
    
    CCDirector::sharedDirector()->pause();
    
    NoTouchLayer* n = NoTouchLayer::create();
    addChild(n, 10, TAG_NO_LAYER);
    
    CCSprite* mask = CCSprite::createWithSpriteFrameName("mask.png");
    mask->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.5f));
    mask->setScaleX(screenSize.width / mask->getContentSize().width * 1.5f);
    mask->setScaleY(screenSize.height / mask->getContentSize().height * 1.5f);
    addChild(mask, 10, TAG_MASK);
    
    CCSprite* pause = CCSprite::createWithSpriteFrameName("pause.png");
    pause->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.68f));
    pause->setScale(1.5f);
    addChild(pause, 10, TAG_TITLE);
    
    CCMenuItemSprite* item = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("resume.png"), NULL, this, menu_selector(GameScene::pauseResume));
    item->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.3f));
    CCMenu* menu = CCMenu::create(item, NULL);
    menu->setPosition(CCPointZero);
    menu->setTouchPriority(-200000);
    addChild(menu, 10, TAG_RESUME);
}
Beispiel #12
0
bool testEffect::init(){
    if ( !CCLayer::init() ){return false;}
    
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("0.GeneralPart.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("MikuFight.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("SheldonFight.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("IronManFight.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("LichKingFight.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("BladeMasterFight.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("FightGeneral.plist");
    
    ASBotFightLayer* aaa = ASBotFightLayer::createAsFightLayer(2, 4,true,1000,1,10000,6,10000,10);
    aaa->setPosition(CCPointZero);
    addChild(aaa,9999,9999);
    
    CCMenu* menu = CCMenu::create();
    for (int i = 1; i < 7 ; i++) {
        string tmp = "card_" + int2string(i) + ".png";
        CCSprite* repeatSprite = CCSprite::createWithSpriteFrameName(tmp.c_str());
        CCMenuItemSprite* repeat = CCMenuItemSprite::create(repeatSprite,repeatSprite,this,menu_selector(testEffect::Repeat));
        repeat->setScale(0.45);
        repeat->setPosition(ccp(size.width/7 + size.width*(i-1)/7,size.height/8));
        repeat->setTag(i);
        menu->addChild(repeat);
    }
    menu->setPosition(CCPointZero);
    addChild(menu,10000);

    return true;
}
Beispiel #13
0
bool GameReviveLayer::init()
{
	if(!CCLayer::init())
		return false;

	CCSize size = ToolsFun::sharedTools()->getSceneSize();
	CCSprite *bkgSprite = CCSprite::create("DayReward/bkg.png");
	this->addChild(bkgSprite, 3);
	bkgSprite->setPosition(size / 2);

	CCMenu *menu = CCMenu::create();
	menu->setPosition(CCPointZero);
	bkgSprite->addChild(menu, 1);

	CCSprite *closeNor = CCSprite::create("ui/shared/closeTipNml.png");
	CCSprite *closeSel = CCSprite::create("ui/shared/closeTipNml.png");
	closeSel->setColor(ccc3(80, 80, 80));
	CCMenuItemSprite *closeItem = CCMenuItemSprite::create(closeNor, closeSel, this, menu_selector(GameReviveLayer::close));
	closeItem->setPosition(ccp(bkgSprite->getContentSize().width * 5 / 6, bkgSprite->getContentSize().height * 6 / 7));
	menu->addChild(closeItem, 144);

	CCSprite *getNor = CCSprite::create("ui/shared/continueGame.png");
	CCSprite *getSel = CCSprite::create("ui/shared/continueGame.png");
	getSel->setColor(ccc3(80, 80, 80));
	CCMenuItemSprite *getItem = CCMenuItemSprite::create(getNor, getSel, this, menu_selector(GameReviveLayer::purchase));
	getItem->setPosition(ccp(bkgSprite->getContentSize().width / 2, 10*gScaleY));
	menu->addChild(getItem, 144);
	

	CCSprite *tip1 = CCSprite::create("DayReward/advanced.png");
	bkgSprite->addChild(tip1);
	tip1->setPosition(ccp(bkgSprite->getContentSize().width/2,bkgSprite->getContentSize().height/2-50*gScaleY));

	/*
	char buf[32];
	sprintf(buf,"%d",6);
	CCLabelTTF *label = CCLabelTTF::create(buf,"΢ÈíÑźÚ",38);
	getItem->addChild(label);
	label->setScale(0.6f);
	label->setColor(ccc3(220 ,220 ,220));
	label->setPosition(ccp(bkgSprite->getPositionX()/2,bkgSprite->getPositionY()/2 ));*/

	registerNDK();

	return true;
}
void StatusUpgrade::addElements(std::string name, CCPoint position){
    CCLabelTTF* strength = CCLabelTTF::create(name.c_str(), "Thonburi", 10);
    strength->setAnchorPoint(ccp(0,0.5));
    strength->setPosition(ccp(30, position.y));
    strength->setColor(ccc3(0,0,0));
    this->addChild(strength, 1);
    
    CCLabelTTF* currentLabel = CCLabelTTF::create(CCString::createWithFormat("%d", this->_current)->getCString(), "arial", 10);
    currentLabel->setAnchorPoint(ccp(0,0.5));
    currentLabel->setPosition(ccp(90, position.y));
    currentLabel->setColor(ccc3(0,0,0));
    this->addChild(currentLabel);
    
    char* desc = this->getDescription(name);
    CCLabelTTF* description = CCLabelTTF::create(desc, "Thonburi", 8);
    description->setAnchorPoint(ccp(0,0.5));
    description->setPosition(ccp(35, position.y - 20));
    description->setColor(ccc3(0,0,0));
    this->addChild(description);
    
    afterLabel   = CCLabelTTF::create(CCString::createWithFormat("-> %d", this->_current + this->_currentAddition)->getCString(), "arial", 10);
    afterLabel->setAnchorPoint(ccp(0, 0.5));
    afterLabel->setPosition(ccp(120, position.y));
    afterLabel->setColor(ccc3(0,0,0));
    this->addChild(afterLabel);
    
    CCSprite* plus = CCSprite::createWithSpriteFrameName("plus.png");
    CCSprite* plusOff = CCSprite::createWithSpriteFrameName("plus.png");
    plusOff->setColor(ccc3(102,102,102));
    CCMenuItemSprite* pPlusButton =
        CCMenuItemSprite::create(plus, plusOff, this, menu_selector(StatusUpgrade::plus));
    
    CCSprite* minus = CCSprite::createWithSpriteFrameName("minus.png");
    CCSprite* minusOff = CCSprite::createWithSpriteFrameName("minus.png");
    minusOff->setColor(ccc3(102,102,102));
    CCMenuItemSprite* pMinusButton =
        CCMenuItemSprite::create(minus, minusOff, this, menu_selector(StatusUpgrade::minus));
    
    pPlusButton->setPosition(ccp(position.x - 90, position.y));
    pMinusButton->setPosition(ccp(position.x - 50, position.y));
    CCMenu* pMenu = CCMenu::create(pPlusButton, pMinusButton, NULL);
 //   pMenu->setTouchPriority(kLevelUpLayerMenuPriority);
    pMenu->setPosition(CCPointZero);
    
    this->addChild(pMenu);
}
Beispiel #15
0
void AsMessageBox::initShareMessageBox(int subType){
    
    if(!MainUser->muted)
        CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("openFrame.wav");
    
    shareImageIndex = subType;
    
    //1.截屏
    if (subType == 1) {
        CCRenderTexture* pScreen = CCRenderTexture::create(winSize.width,winSize.height);
        CCScene* pCurScene = CCDirector::sharedDirector()->getRunningScene();
        pScreen->begin();
        pCurScene->visit();
        pScreen->end();
        pScreen->saveToFile("shared.png",kCCImageFormatPNG);
    }

    //2.黑色底层
    cover = CCLayerColor::create(ccc4(0,0,0,200));
    cover->setPosition(CCPointZero);
    addChild(cover,0);
    
    //3.提示框底层
    showbox = CCSprite::createWithSpriteFrameName("shareFrame.png");
    showbox->setScaleY(1.1);
    showbox->setPosition(ccp(size.width/2,size.height/2+winDif*2*alpha));
    cover->addChild(showbox,1);
    
    //4.提示框上的文字
    CCSprite* shareWeixinSprite = CCSprite::createWithSpriteFrameName("shareWeixin.png");
    CCSprite* shareWeixinSprite_s = CCSprite::createWithSpriteFrameName("shareWeixin-s.png");
    CCSprite* shareWeixin1Sprite = CCSprite::createWithSpriteFrameName("shareWeixin1.png");
    CCSprite* shareWeixin1Sprite_s = CCSprite::createWithSpriteFrameName("shareWeixin1-s.png");
    CCSprite* closeSprite = CCSprite::createWithSpriteFrameName("closeMatchTable.png");
    CCSprite* closeSprite_s = CCSprite::createWithSpriteFrameName("closeMatchTable-s.png");
    CCMenuItemSprite* closeItem = CCMenuItemSprite::create(closeSprite,closeSprite_s,this,menu_selector(AsMessageBox::closeMessageBox));
    CCMenuItemSprite* item1 = CCMenuItemSprite::create(shareWeixinSprite,shareWeixinSprite_s,this,menu_selector(AsMessageBox::goShare));
    CCMenuItemSprite* item2 = CCMenuItemSprite::create(shareWeixin1Sprite,shareWeixin1Sprite_s,this,menu_selector(AsMessageBox::goShare));
    item1->setTag(10);
    item2->setTag(11);
    item1->setPosition(ccp(size.width*18/50,size.height*10/20+winDif*2.18*alpha));
    item2->setPosition(ccp(size.width*32/50,size.height*10/20+winDif*2.18*alpha));
    closeItem->setPosition(ccp(size.width*5.7/7,size.height*11.5/20+winDif*2.18*alpha));
    closeMenu = CCMenu::create(item1,item2,closeItem,NULL);
    closeMenu->setPosition(CCPointZero);
    addChild(closeMenu,2);
    
    //5.文字提示
    CCLabelTTF* shareToIndiLabel = CCLabelTTF::create("分享给朋友","Arial Rounded MT Bold",24);
    CCLabelTTF* shareToCircleLabel = CCLabelTTF::create("分享到朋友圈","Arial Rounded MT Bold",24);
    shareToIndiLabel->setColor(ccc3(55, 55, 55));
    shareToCircleLabel->setColor(ccc3(55, 55, 55));
    shareToIndiLabel->setPosition(ccp(size.width*18/50,size.height*8/20+winDif*2.18*alpha));
    shareToCircleLabel->setPosition(ccp(size.width*32/50,size.height*8/20+winDif*2.18*alpha));
    addChild(shareToIndiLabel,7,53);
    addChild(shareToCircleLabel,7,54);
    
}
void GameScene::showGameOver() {
    CCSprite* over = CCSprite::createWithSpriteFrameName("gameOver.png");
    over->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.7f));
    over->setScale(1.5f);
    addChild(over, 10);
    
    CCSprite* scoreBoard = CCSprite::createWithSpriteFrameName("score_board.png");
    scoreBoard->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.5f));
    scoreBoard->setScale(1.5f);
    addChild(scoreBoard, 10);
    
    CCLabelAtlas* curScore = CCLabelAtlas::create(CCString::createWithFormat("%d", gameScore)->getCString(), "score_number.png", 30, 45, '0');
    curScore->setAnchorPoint(ccp(1, 0.5f));
    curScore->setScale(0.75f);
    curScore->setPosition(ccp(screenSize.width * 0.78f, screenSize.height * 0.53f));
    addChild(curScore, 10);
    
    int maxScore = CCUserDefault::sharedUserDefault()->getIntegerForKey("MAX", 0);
    if (gameScore > maxScore) {
        maxScore = gameScore;
        CCUserDefault::sharedUserDefault()->setIntegerForKey("MAX", gameScore);
        CCUserDefault::sharedUserDefault()->flush();
        CCSprite* showNew = CCSprite::createWithSpriteFrameName("new.png");
        showNew->setAnchorPoint(ccp(0, 0.5f));
        showNew->setScale(1.5f);
        showNew->setPosition(ccp(screenSize.width * 0.78f, screenSize.height * 0.45f));
        addChild(showNew, 10);
    }
    
    CCLabelAtlas* highScore = CCLabelAtlas::create(CCString::createWithFormat("%d", maxScore)->getCString(), "score_number.png", 30, 45, '0');
    highScore->setAnchorPoint(ccp(1, 0.5f));
    highScore->setScale(0.75f);
    highScore->setPosition(ccp(screenSize.width * 0.78f, screenSize.height * 0.45f));
    addChild(highScore, 10);
    
    removeChildByTag(999);
    
    CCMenuItemSprite* item = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("start.png"), CCSprite::createWithSpriteFrameName("start.png"), this, menu_selector(GameScene::restart));
    item->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.3f));
    CCMenu* menu = CCMenu::create(item, NULL);
    menu->setPosition(CCPointZero);
    addChild(menu, 10);
    
    if (gameScore >= 10) {
        CCSprite* metalName = NULL;
        if (gameScore >= 10 && gameScore < 50) {
            metalName = CCSprite::createWithSpriteFrameName("medals_1.png");
        } else if (gameScore >= 50 && gameScore < 100) {
            metalName = CCSprite::createWithSpriteFrameName("medals_2.png");
        } else if (gameScore >= 100) {
            metalName = CCSprite::createWithSpriteFrameName("medals_3.png");
        }
        metalName->setScale(1.5f);
        metalName->setPosition(ccp(screenSize.width * 0.3f, screenSize.height * 0.495f));
        addChild(metalName, 10);
    }
}
Beispiel #17
0
void CardScene::initMenu()
{
	CCSprite* backButtonSprite = CCSprite::create("backArrow.png");
	CCSprite* backButtonSpriteSel = CCSprite::create("backArrow.png");
	backButtonSpriteSel->setScale( 0.9 );

	CCSprite* shopButtonSprite = CCSprite::create("shop.png");
	CCSprite* shopButtonSpriteSel = CCSprite::create("shop.png");
	shopButtonSpriteSel->setScale( 0.9 );

	CCMenuItemSprite* backButton = CCMenuItemSprite::create(backButtonSprite, backButtonSpriteSel, this, menu_selector(CardScene::onBackButtonAction));
	backButton->setPosition( ccp(650, 930) );
	
	CCMenuItemSprite* shopButton = CCMenuItemSprite::create(shopButtonSprite, shopButtonSpriteSel, this, menu_selector(CardScene::onShopButtonAction));
	shopButton->setPosition( ccp(100, 930) );

	CCMenu* menu = CCMenu::create(backButton, shopButton, NULL);
	menu->setPosition(0, 0);
	addChild( menu );
}
Beispiel #18
0
void PlayScene::setupRemindLayer()
{
  mReminder = CCLayer::create();
  CCSprite* btn = CCSprite::create("Images/Game/UI/buttonPlay.png");
  CCMenuItemSprite* item = CCMenuItemSprite::create(btn, btn, this, menu_selector(PlayScene::onResume));
  CCPoint centerPos = ccp(SCREEN_SIZE.width/2, SCREEN_SIZE.height/2);
  item->setPosition(centerPos);
  CCMenu* menu = CCMenu::create(item, NULL);
  mReminder->addChild(menu);
  mReminder->setVisible(false);
  menu->setPosition(CCPointZero);
  this->addChild(mReminder);
}
void ParkingViewScene::LoadParkingId()
{
    CCNode* node = this->getChildByTag(250);
    char s[20] ;

    sprintf(s, "%d.png", this->wayPointID);
    
    CCSprite *sprtEstabelecimento = CCSprite::create(s);
    if( sprtEstabelecimento == 0)
        sprtEstabelecimento = CCSprite::create("ModeloWayPointFoto.png");
    
    sprtEstabelecimento->setAnchorPoint(ccp(0,0));
    sprtEstabelecimento->setPosition(ccp(0,217));
    node->addChild(sprtEstabelecimento);

    
    //Waypoints do estacionamentos sao referidos como retirada de veiculos, de acordo
    //com o id, aqui o texto é alterado.
    switch(wayPointID)
    {
        case 19:
            insertLabel(ccc3(72, 72, 72), ccp(20, 180), true, "Bloco A1", node, 16);
            break;
        case 51:
            insertLabel(ccc3(72, 72, 72), ccp(20, 180), true, "Bloco B", node, 16);
            break;
        case 89:
            insertLabel(ccc3(72, 72, 72), ccp(20, 180), true, "Bloco D/E", node, 16);
            break;
    }
 

    //Cria um label ( aqui vira descricao do estacionamento)
    insertLabel(ccc3(72, 72, 72), ccp(20, 160), false, "Auditorio Moise Safra", node, 12);
    
    CCSprite *btnHorarioSelected = CCSprite::create("btnShowRotaEstacionmanto.png"); // botao pressionado
    CCSprite *btnHorarioUnSelected = CCSprite::create("btnShowRotaEstacionmanto.png");//botao nao pressionado
    CCMenuItemSprite *itembtnHorario = CCMenuItemSprite::create(btnHorarioSelected, btnHorarioUnSelected, btnHorarioSelected, menu_selector(ParkingViewScene::btnRotaCallBack));
	itembtnHorario->setAnchorPoint(ccp(0, 0));
    itembtnHorario->setPosition(ccp(40, 0));
    
    CCMenu* options = CCMenu::create();
    options->addChild(itembtnHorario,0,wayPointID);
    options->setPosition(ccp(230, 171) );
    node->addChild(options);
    
    CCSprite *sprtFundoEstabelecimento = CCSprite::create("SombraMagica.png");
    sprtFundoEstabelecimento->setAnchorPoint(ccp(0,0));
    sprtFundoEstabelecimento->setPosition(ccp(72, 200));
    node->addChild(sprtFundoEstabelecimento);
}
Beispiel #20
0
void ASGame::energyBarAnimation(){
    
    //1.显示行动力的圆形底座
    CCSprite* energyBall = CCSprite::createWithSpriteFrameName("newEnergyContainer.png");
    energyBall->setPosition(ccp(size.width*17.38/80,size.height*77.85/90+winDif*2*alpha*alpha));
    addChild(energyBall,4);
    
    //2.行动力数量
    string perStr = int2string(moveCount);
    CCLabelTTF* per = CCLabelTTF::create(perStr.c_str(),"Arial Rounded MT bold",32);
    per->setPosition(ccp(size.width*17.38/80,size.height*77.85/90+winDif*2*alpha*alpha));
    addChild(per,5,1*10000000+26);
    
    //3.能量条
    CCSprite* energyBarSprite = CCSprite::createWithSpriteFrameName("newEnergyBar.png");
    CCProgressTimer* energyBar = CCProgressTimer::create(energyBarSprite);
    energyBar->setPosition(ccp(size.width*8.45/80,size.height*79.89/90+winDif*2*alpha*alpha));
    energyBar->setType(kCCProgressTimerTypeRadial);
    energyBar->setPercentage(moveCount*20);
    addChild(energyBar,4,1*10000000+20);
    
    //4.攻击按钮底座
    CCSprite* containerSprite = CCSprite::createWithSpriteFrameName("energyContainer.png");
    CCSprite* containerSprite_s = CCSprite::createWithSpriteFrameName("energyContainer.png");
    CCMenuItemSprite* energyContainer = CCMenuItemSprite::create(containerSprite,containerSprite_s,this,menu_selector(ASGame::enterFightLayer));
    energyContainer->setScale(1.05);
    energyContainer->setPosition(ccp(size.width*179.5/200,size.height*10.25/135));
    CCMenu* energyContainerMenu = CCMenu::create(energyContainer,NULL);
    energyContainerMenu->setPosition(CCPointZero);
    if (moveCount < moveToFight)
            energyContainerMenu->setTouchEnabled(false);
    addChild(energyContainerMenu,2,1*10000000+27);
    
    //5.攻击按钮充值槽
    CCSprite* barSprite = CCSprite::createWithSpriteFrameName("energyBar.png");
    CCProgressTimer* attackButton = CCProgressTimer::create(barSprite);
    attackButton->setScale(1.05);
    attackButton->setPosition(ccp(size.width*179.04/200,size.height*10/135));
    attackButton->setType(kCCProgressTimerTypeBar);
    attackButton->setMidpoint(ccp(0.5, 0));
    attackButton->setBarChangeRate(ccp(0, 1));
    attackButton->setPercentage(100*moveCount/moveToFight);
    addChild(attackButton,3,1*10000000+25);
    
    //4.能量的盖子
    CCSprite* energyBarCover = CCSprite::createWithSpriteFrameName("energyBarCover.png");
    energyBarCover->setPosition(ccp(size.width*179.5/200,size.height*10.25/135));
    energyBarCover->setOpacity(0);
    //addChild(energyBarCover,4,1*10000000+28);
}
Beispiel #21
0
bool FairyMenu::init()
{
    bool bRet = false;
    do 
    {
        CC_BREAK_IF(! CCLayer::init());
		AnimatePacker::getInstance()->loadAnimations("skill/loading.xml"); 
		CCString *fileName = CCString::createWithFormat(BattleMusic, 2);
		SimpleAudioEngine::sharedEngine()->playBackgroundMusic(fileName->getCString(), true);
        CCSize size = CCDirector::sharedDirector()->getWinSize();
		CCSprite *fairyMenuBack = CCSprite::create(menuBack);
		this->addChild(fairyMenuBack);
		fairyMenuBack->setPosition(ccp(size.width / 2, size.height / 2));
		CCSprite *fairyMenuMenu = CCSprite::create(menuMenu);
		this->addChild(fairyMenuMenu);
		fairyMenuMenu->setPosition(ccp(size.width / 2, size.height / 2 - 100));
		CCSprite *menuLoading=CCSprite::create();
		this->addChild(menuLoading);
		menuLoading->setPosition(ccp(size.width/2, size.height/2 + 60));
		menuLoading->runAction(CCRepeatForever::create(AnimatePacker::getInstance()->getAnimate("loading")));
		int itemPosition[3][2]  = {{5, 0 - 90 }, {5, -205}, {5, 0 - 310}};
		XMLParser *scene = XMLParser::parseWithFile("data/common.xml");
		CCString* menuStart = scene->getString("menu_start");
		CCString* menuIntro = scene->getString("menu_intro");
		CCString* menuExit = scene->getString("menu_exit");
		CCMenu* menu = CCMenu::create();
		for(int i =0; i < 3; i++){
			CCSprite* fairyMenuButton = CCSprite::create(menuItem);
			CCMenuItemSprite* fairyMenuButtonItem = CCMenuItemSprite::create(fairyMenuButton, fairyMenuButton, this, menu_selector(FairyMenu::fairyMenuCallback));
			fairyMenuButtonItem->setPosition(ccp(itemPosition[i][0] ,itemPosition[i][1]));
			fairyMenuButtonItem->setTag(i + 1);
			menu->addChild(fairyMenuButtonItem);
		}
		this->addChild(menu);
		CCLabelTTF* fairyMenuStart = CCLabelTTF::create(menuStart->getCString(), "Arial", 30);
		this->addChild(fairyMenuStart);
		fairyMenuStart->setPosition(ccp(size.width/2, size.height/2 - 90));
		CCLabelTTF* fairyMenuIntro = CCLabelTTF::create(menuIntro->getCString(), "Arial", 30);
		this->addChild(fairyMenuIntro);
		fairyMenuIntro->setPosition(ccp(size.width/2, size.height/2 - 204));
		CCLabelTTF* fairyMenuExit = CCLabelTTF::create(menuExit->getCString(), "Arial", 30);
		this->addChild(fairyMenuExit);
		fairyMenuExit->setPosition(ccp(size.width/2, size.height/2 - 310));
        bRet = true;
    } while (0);

    return bRet;
}
bool GameScene::init()
{
    screenSize = CCDirector::sharedDirector()->getWinSize();
    
    int r = CCRANDOM_0_1() * 10;
    
    CCSprite* bg = NULL;
    if (r >= 5) {
        bg = CCSprite::createWithSpriteFrameName("bg_day.png");
    } else {
        bg = CCSprite::createWithSpriteFrameName("bg_night.png");
    }
    bg->setAnchorPoint(ccp(0, 0));
    bg->setPosition(ccp(0, 0));
    addChild(bg, 0);
    
    CCSprite* land0 = CCSprite::createWithSpriteFrameName("land.png");
    land0->setAnchorPoint(ccp(0, 0));
    land0->setPosition(ccp(0, 0));
    addChild(land0, 3, TAG_LAND);
    CCMoveBy* move = CCMoveBy::create(1.0f, ccp(-land0->getContentSize().width * 0.25f, 0));
    CCCallFuncN* call = CCCallFuncN::create(this, callfuncN_selector(GameScene::removeNodeSelf));
    CCSequence* seq = CCSequence::create(move, call, NULL);
    land0->runAction(seq);
    
    randomValue = 0;
    gameScore = 0;
    isGameOver = false;
    isShowingHint = true;
    
    pipeArray = CCArray::create();
    CC_SAFE_RETAIN(pipeArray);
    hitCheckArray = CCArray::create();
    CC_SAFE_RETAIN(hitCheckArray);
    
    createBird();
    showHint();
    
    CCMenuItemSprite* pauseItem = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("button_pause.png"), NULL, this, menu_selector(GameScene::touchPauseCallBack));
    pauseItem->setPosition(ccp(screenSize.width * 0.92f, screenSize.height * 0.95f));
    pauseItem->setScale(2.0f);
    CCMenu* m = CCMenu::create(pauseItem, NULL);
    m->setPosition(CCPointZero);
    addChild(m, 10);
    
    M3AudioManager::shareInstance();
    return true;
}
bool RPGMapItemsMenuLayer::init(cocos2d::CCDictionary *stringList, CppSQLite3DB *db, float width, float height)
{
    if(CCLayerColor::initWithColor(ccc4(0, 0, 0, 200), width, height))
    {
        this->m_stringList = stringList;
        this->m_stringList->retain();
        
        this->m_db = db;
        
        this->m_itemsList = new CCArray();
        this->m_itemsList->init();
        
        CCTMXTiledMap *mainBg = CCTMXTiledMap::create(CCString::createWithFormat("map_menu3_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
        mainBg->setPosition(CCPointZero);
        mainBg->setTag(kRPGMapItemsMenuLayerTagBg);
        this->addChild(mainBg);
        
        CCMenu *mainMenu = CCMenu::create();
        mainMenu->setTag(kRPGMapItemsMenuLayerTagMainMenu);
        mainMenu->setAnchorPoint(CCPointZero);
        mainMenu->setPosition(CCPointZero);
        this->addChild(mainMenu);
        
        CCMenuItemSprite *menuBack = (CCMenuItemSprite*)mainMenu->getChildByTag(kRPGMapItemsMenuLayerTagMainMenuBack);
        if(!menuBack)
        {
            menuBack = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGMapItemsMenuLayer::onMenu));
            menuBack->setPosition(ccp(40, 600));
            menuBack->setTag(kRPGMapItemsMenuLayerTagMainMenuBack);
            menuBack->setScale(0.5);
            mainMenu->addChild(menuBack);
        }
        
        CCTableView *tableView = CCTableView::create(this, CCSizeMake(900, 570));
        tableView->setDirection(kCCScrollViewDirectionVertical);
        tableView->setPosition(ccp(80, 30));
        tableView->setDelegate(this);
        tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
        tableView->setTag(kRPGMapItemsMenuLayerTagItemListTable);
        this->addChild(tableView);
        
        this->loadItemsData();
        
        return true;
    }
    return false;
}
//private
void RPGMapSceneLayer::startPlay(float delay)
{
    CCTMXTiledMap *bgMap = (CCTMXTiledMap*)this->getChildByTag(kRPGMapSceneLayerTagBgMap);
    
    //数据库部分,读取npc数据
    CppSQLite3Query query = this->m_db.execQuery(CCString::createWithFormat(NPC_QUERY, this->m_mapData.mapId)->getCString());
    while(!query.eof())
    {
        float x = (stringToNumber<float>(query.getStringField("tmx_x")) + 0.5) * GAME_TMX_ROLE_WIDTH;
        float y = (stringToNumber<float>(query.getStringField("tmx_y")) + 0.5) * GAME_TMX_ROLE_HEIGHT;
        bool autoMove = query.getIntField("auto_move") == 1 ? true : false;
        
        RPGMapNPCRoleSprite *npc = RPGMapNPCRoleSprite::create(query.getIntField("id"), CCString::create(query.getStringField("map_texture")), CCString::create("head_texture"), CCString::create(query.getStringField("name_cns")), CCString::create(query.getStringField("content_cns")), 1, autoMove);
        npc->setTag(kRPGMapSceneLayerTagNPC + query.getIntField("id"));
        npc->setPosition(ccp(x, y));
        bgMap->addChild(npc);
        
        query.nextRow();
    }
    query.finalize();
    
    //player
    int defaultSpriteFrameIndex = 1; //默认为向下
    if(this->m_mapData.playerDirection.compare("up") == 0)
    {
        defaultSpriteFrameIndex = 10;
    }
    else if(this->m_mapData.playerDirection.compare("left") == 0)
    {
        defaultSpriteFrameIndex = 4;
    }
    else if(this->m_mapData.playerDirection.compare("right") == 0)
    {
        defaultSpriteFrameIndex = 7;
    }
    RPGMapRoleSprite *player = RPGMapRoleSprite::create(CCString::create("actor4_0.png"), CCString::create("Player"), true, defaultSpriteFrameIndex);
    player->setPosition(ccp(this->m_mapData.playerToX * GAME_TMX_ROLE_WIDTH, this->m_mapData.playerToY * GAME_TMX_ROLE_HEIGHT));
    player->setTag(kRPGMapSceneLayerTagPlayer);
    player->m_type = kRPGMapRoleSpriteTypePlayer;
    bgMap->addChild(player);
    
    CCSprite *spJoystick = CCSprite::createWithSpriteFrameName("Ball.png");
    CCSprite *joystickBg = CCSprite::createWithSpriteFrameName("Dock.png");
    OzgJoystickLayer *joystick = OzgJoystickLayer::layerActivityJoystick(50, spJoystick, joystickBg, false);
    joystick->setTag(kRPGMapSceneLayerTagJoystick);
    joystick->m_target = this;
    joystick->m_endedSelector = callfunc_selector(RPGMapSceneLayer::joystickEndedFunc);
    this->addChild(joystick);
    
    //menu
    CCMenu *mainMenu = CCMenu::create();
    mainMenu->setTag(kRPGMapSceneLayerTagMainMenu);
    mainMenu->setAnchorPoint(ccp(0.5, 0.5));
    mainMenu->setPosition(CCPointZero);
    mainMenu->setContentSize(bgMap->getContentSize());
    bgMap->addChild(mainMenu);

    CCMenuItemSprite *menuCommand = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGMapSceneLayer::onMenu));
    menuCommand->setPosition(ccp(mainMenu->getContentSize().width - 35, mainMenu->getContentSize().height - 35));
    menuCommand->setTag(kRPGMapSceneLayerTagMainMenuCommand);
    menuCommand->setRotation(180);
    menuCommand->setScale(0.75);
    mainMenu->addChild(menuCommand);

//    CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo();
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 1, true);
    this->scheduleUpdate();
    
}
Beispiel #25
0
bool S3PracticeScene::init()
{
	bool bRet = false;
	do 
	{
		CC_BREAK_IF(! CCLayer::init());
        
        
		//每个项目都要创建的东西

		_menu = CCMenu::create(NULL);
		_menu->setPosition(CCPointZero);
		CC_BREAK_IF(! _menu);

		this->addChild(_menu, 2);

        
	
        //NavBar及背景图
        
        {
            {
                CCSprite * aSprite = CCSprite::create("pBackground.png");
                aSprite->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
                //CC_BREAK_IF(! aSprite);
                this->addChild(aSprite,1);
                aSprite ->getTexture()->setAntiAliasTexParameters();//抗锯齿
            }
            
            {
                CCSprite * aSprite = CCSprite::create("pNavBar.png");
                aSprite->setPosition(s3Position2_macro(aSprite));
                //CC_BREAK_IF(! aSprite);
                this->addChild(aSprite,1);
            }
            
            {
                CCLabelTTF * titleLabel = CCLabelTTF::create("Practice", "Arial", s3FontSize1_macro);
                titleLabel->setPosition(s3Position1_macro(aItem));
                //CC_BREAK_IF(! aSprite);
                this->addChild(titleLabel,1);
            }
        }
		
        
        
        //TabBar及按钮
        
        {
            //TabBar
            {
                CCSprite * aSprite = CCSprite::create("pTabBar.png");
                aSprite->setPosition(CCPointZero);
                aSprite->setAnchorPoint(CCPointZero);
                //CC_BREAK_IF(! aSprite);
                this->addChild(aSprite,1);
            }
            
            //GRE模考按钮
            {
                CCSprite * sprite1 = CCSprite::create("pPencilIconActive.png");
                CCSprite * sprite2 = CCSprite::create("pPencilIconActive.png");
                CCMenuItemSprite *aItem = CCMenuItemSprite::create(
                                                                   sprite1,
                                                                   sprite2,
                                                                   this,
                                                                   menu_selector(S3PracticeScene::menuOnPencil));
                CC_BREAK_IF(! aItem);
                aItem->setPosition(s3Position5_macro(aItem));
                _menu ->addChild(aItem,1);
            }
            
            //备考资料按钮
            {
                CCSprite * sprite1 = CCSprite::create("pDocumentIcon.png");
                CCSprite * sprite2 = CCSprite::create("pDocumentIconActive.png");
                CCMenuItemSprite *aItem = CCMenuItemSprite::create(
                                                                   sprite1,
                                                                   sprite2,
                                                                   this,
                                                                   menu_selector(S3PracticeScene::menuOnDocument));
                CC_BREAK_IF(! aItem);
                aItem->setPosition(s3Position6_macro(aItem));
                _menu ->addChild(aItem,1);
            }
            
            //设置按钮
            {
                CCSprite * sprite1 = CCSprite::create("pSettingsIcon.png");
                CCSprite * sprite2 = CCSprite::create("pSettingsIconActive.png");
                CCMenuItemSprite *aItem = CCMenuItemSprite::create(
                                                                   sprite1,
                                                                   sprite2,
                                                                   this,
                                                                   menu_selector(S3PracticeScene::menuOnSettings));
                CC_BREAK_IF(! aItem);
                aItem->setPosition(s3Position7_macro(aItem));
                _menu ->addChild(aItem,1);
            }
            
        }
        
        
		//控件
	
        {
			CCSprite * sprite1 = CCSprite::create("pBackButton.png");
			CCSprite * sprite2 = CCSprite::create("pBackButton.png");
            
			CCMenuItemSprite *aItem = CCMenuItemSprite::create(
                sprite1,
                sprite2,
                this,
                menu_selector(S3PracticeScene::menuOnBackCallback));
			CC_BREAK_IF(! aItem);
			aItem->setPosition(s3Position3_macro(aItem));
			_menu ->addChild(aItem,1);
            
            
            CCLabelTTF *label_back = CCLabelTTF::create("GRE模考", "Arial", s3FontSize2_macro, sprite1->getContentSize(), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
            label_back->setPosition(s3Position3_macro(aItem));
            this ->addChild(label_back,2);
		}
                
        
        CCSprite *spriteBackground = CCSprite::create("s3ElevenRowTable.png");
        spriteBackground->setPosition(s3Position4_macro(aSprite));
        CCLog("spriteBackground.width:%f spriteBackground.height:%f",spriteBackground->getContentSize().width,spriteBackground->getContentSize().height);
        CC_BREAK_IF(! spriteBackground);
        this->addChild(spriteBackground,1);
        
        
		CCTableView* pTableView = CCTableView::create(this, s3Size1_macro(aTableView));
        CC_BREAK_IF(! pTableView);
		pTableView->setDirection(kCCScrollViewDirectionVertical);
        pTableView->setAnchorPoint(CCPointZero);
        pTableView->setPosition(ccp(spriteBackground->getPosition().x-(spriteBackground->getContentSize().width / 2),spriteBackground->getPosition().y-(spriteBackground->getContentSize().height / 2) + s3Less1_macro / 2));
		pTableView->setDelegate(this);
        
        //   设置顺序是自上往下
		pTableView->setVerticalFillOrder(kCCTableViewFillTopDown);
        
		this->addChild(pTableView,1);
        
        {
            std::string str = "Practice 1";
            aVectorCellValue.push_back(str);
        }
        {
            std::string str = "Practice 2";
            aVectorCellValue.push_back(str);
        }
        {
            std::string str = "Practice 3";
            aVectorCellValue.push_back(str);
        }
        {
            std::string str = "Practice 4";
            aVectorCellValue.push_back(str);
        }
        {
            std::string str = "Practice 5";
            aVectorCellValue.push_back(str);
        }
        {
            std::string str = "Practice 6";
            aVectorCellValue.push_back(str);
        }
        {
            std::string str = "Practice 7";
            aVectorCellValue.push_back(str);
        }
        {
            std::string str = "Practice 8";
            aVectorCellValue.push_back(str);
        }
        
		pTableView->reloadData();
        
		bRet = true;
	} while (0);

	return bRet;
}
void AlertViewScene::showMessageParking(CCNode* parent, SEL_MenuHandler callbackFunction  ,int wayPoint)
{
    int basePosition = 50;
    
    float heigth = CCDirector::sharedDirector()->getWinSize().height;
    if (heigth >480) {
        basePosition = 100;//4inch
    }
    
    if( AlertViewScene::isActive ==  true)
        return;
    
    AlertViewScene::isActive = true;
    //Layer - Container with all elements of Alert
    CCLayerColor *node = CCLayerColor::create(ccc4(0,0,0,255));
    node->setContentSize(CCDirector::sharedDirector()->getWinSize());
    node->setOpacity(200);
    node->setAnchorPoint(ccp(0,0));
    node->setPosition(ccp(0,0));

    
    //Fundo do Popup
    CCSprite *sprBackground = CCSprite::create("popup.png");
    sprBackground->setAnchorPoint(ccp(0,0));
    sprBackground->setScale(1);
    sprBackground->setPosition(ccp( 25,basePosition+100));
    node->addChild(sprBackground);

    //Close Button of frame
    CCSprite *btnClose = CCSprite::create("fechar_btn.png");
    CCSprite *btnClosePress = CCSprite::create("fechar_press.png");

    CCSprite *Icone = CCSprite::create("icone_estacionamento.png");
    Icone->setPosition(ccp(45,basePosition+225));
    node->addChild(Icone);
    
    CCMenuItemSprite *itembtnClose = CCMenuItemSprite::create(btnClose, btnClosePress, node, callbackFunction);
	itembtnClose->setAnchorPoint(ccp(0, 0));
	itembtnClose->setPosition(ccp(280,basePosition+303));
    
    //Button Rota para o local
    CCSprite *btnSelect = CCSprite::create("ok_btn.png");
    CCSprite *btnUnselect = CCSprite::create("ok_press.png");
    
    CCMenuItemSprite *itembtnRota = CCMenuItemSprite::create( btnSelect,btnUnselect, node,callbackFunction);
	itembtnRota->setAnchorPoint(ccp(0, 0));
	itembtnRota->setPosition(ccp(115,basePosition+150));
    //Button Rota para o local
    CCMenu* options = CCMenu::create();
    options->addChild(itembtnClose,0,44);
    options->addChild(itembtnRota,0,wayPoint);
    options->setPosition(ccp(0, -20));
    node->addChild(options,3,Global::TAG_Child_Layer);
    
    //Title of Alert
    CCLabelTTF *labelTitle;
    labelTitle = CCLabelTTF::create("Alerta", "LucidaGrandeBold", 16);
    labelTitle->setPosition(ccp(35, basePosition+260));
    labelTitle->setAnchorPoint(ccp(0,0));
    labelTitle->setColor(ccc3(55, 55, 55));
    node->addChild(labelTitle);
    
    
    //sub-Title of Alert
    CCLabelTTF *labelSubTitle;
    labelSubTitle = CCLabelTTF::create("Atenção", "LucidaGrandeBold", 11);
    labelSubTitle->setPosition(ccp(60, basePosition+225));
    labelSubTitle->setAnchorPoint(ccp(0,0));
    labelSubTitle->setColor(ccc3(55, 55, 55));
    node->addChild(labelSubTitle);

    //Description of Alert
    CCLabelTTF *labelDescription;
    labelDescription = CCLabelTTF::create("       Ao entrar por este bloco você só poderá retirar", "Lucida Grande", 10);
    labelDescription->setPosition(ccp(40, basePosition+210));
    labelDescription->setAnchorPoint(ccp(0,0));
    labelDescription->setColor(ccc3(55, 55, 55));
    node->addChild(labelDescription);
    
    //Description of Alert
    CCLabelTTF *labelDescription2;
    labelDescription2 = CCLabelTTF::create("seu veículo neste mesmo bloco.", "Lucida Grande", 10);
    labelDescription2->setPosition(ccp(35, basePosition+200));
    labelDescription2->setAnchorPoint(ccp(0,0));
    labelDescription2->setColor(ccc3(55, 55, 55));
    node->addChild(labelDescription2);


    parent->addChild(node,10,Global::TAG_Alert_Layer);
}
void AlertViewScene::showMessageParkingOption(CCNode* sender, SEL_MenuHandler entering,SEL_MenuHandler outing,SEL_MenuHandler quiting)
{
    
    if( AlertViewScene::isActive ==  true)
        return;
    AlertViewScene::isActive = true;
    
    CCSprite *sprBackground = CCSprite::create("bg_parking_4inch.png");
    sprBackground->setAnchorPoint(ccp(0,0));
    //sprBackground->setScale(1);
    sprBackground->setPosition(ccp(0,0));
    
    
    //Backgroud Alert
    CCSprite *sprBackground2 = CCSprite::create("popup.png");
    sprBackground2->setAnchorPoint(ccp(0,0));
    //sprBackground2->setScale(1);
    sprBackground2->setPosition(ccp(25,200));
    
    //Layer - Container with all elements of Alert
    CCLayerColor *node = CCLayerColor::create(ccc4(0,0,0,200));
  //  node->setContentSize(CCDirector::sharedDirector()->getWinSize());
    //node->addChild(sprBackground,1);
    node->addChild(sprBackground2,22);
    //node->setOpacity(200);
    node->setAnchorPoint(ccp(0,0));
    node->setPosition(ccp(0,0));

    //Close Button of frame
    CCSprite *btnClose = CCSprite::create("fechar_btn.png");
    CCSprite *btnClosePress = CCSprite::create("fechar_press.png");
    
    CCSprite *Icone = CCSprite::create("icon_car.png");
    Icone->setPosition(ccp(45,325));
    node->addChild(Icone,23);
    
    CCMenuItemSprite *itembtnClose = CCMenuItemSprite::create(btnClose, btnClosePress, node, quiting);
	itembtnClose->setAnchorPoint(ccp(0, 0));
	itembtnClose->setPosition(ccp(280,380));
    
    
    
    //Button Rota para o local
    CCSprite *imgEntering = CCSprite::create("button_entering.png");
    CCSprite *imgEnteringPress = CCSprite::create("button_entering_press.png");
    
    
    CCMenuItemSprite *btnEntering = CCMenuItemSprite::create( imgEnteringPress,imgEntering, node,entering);
	btnEntering->setAnchorPoint(ccp(0, 0));
	btnEntering->setPosition(ccp(70,250));
    
    CCSprite *imgOuting = CCSprite::create("button_outing.png");
    CCSprite *imgOutingPress = CCSprite::create("button_outing_press.png");
    
    CCMenuItemSprite *btnOuting = CCMenuItemSprite::create( imgOutingPress,imgOuting, node,outing);
	btnOuting->setAnchorPoint(ccp(0, 0));
	btnOuting->setPosition(ccp(170,250));

    
    CCMenu* options = CCMenu::create();
    options->addChild(itembtnClose,0,44);
    options->addChild(btnEntering,15,84);
    options->addChild(btnOuting,16,84);
    options->setPosition(ccp(0, 0));
    node->addChild(options,24,Global::TAG_Child_Layer);
    
    
    //Title of Alert
    CCLabelTTF *labelTitle;
    labelTitle = CCLabelTTF::create("Você está:", "LucidaGrandeBold", 16);
    labelTitle->setPosition(ccp(35, 360));
    labelTitle->setAnchorPoint(ccp(0,0));
    labelTitle->setColor(ccc3(55, 55, 55));
    node->addChild(labelTitle,25);
    
    
    
    //Description of Alert
    CCLabelTTF *labelDescription;
    labelDescription = CCLabelTTF::create("       Você está saindo ou entrando?", "Lucida Grande", 12);
    labelDescription->setPosition(ccp(40, 320));
    labelDescription->setAnchorPoint(ccp(0,0));
    labelDescription->setColor(ccc3(55, 55, 55));
    node->addChild(labelDescription,26);
//
// 
//
//    
//   // ((CCLayerColor*)sender)->setOpacity(30);
//    CCDirector::sharedDirector()->getRunningScene()->addChild(node,10,Global::TAG_Alert_Layer);


        sender->addChild(node, 30, Global::TAG_Alert_Layer);
    
  
}
void AlertViewScene::showMessageRota(CCNode* sender, SEL_MenuHandler callbackFunction ,int wayPoint)
{
    if( AlertViewScene::isActive ==  true)
        return;
    AlertViewScene::isActive = true;

    //Backgroud Alert
    CCSprite *sprBackground = CCSprite::create("popup.png");
    sprBackground->setAnchorPoint(ccp(0,0));
    sprBackground->setScale(1);
    sprBackground->setPosition(ccp(25,100));
    
    //Layer - Container with all elements of Alert
    CCLayerColor *node = CCLayerColor::create(ccc4(0,0,0,255));
    node->setContentSize(CCDirector::sharedDirector()->getWinSize());
    node->addChild(sprBackground);
    node->setOpacity(200);
    node->setAnchorPoint(ccp(0,0));
    node->setPosition(ccp(0,0));

    //Close Button of frame
    CCSprite *btnClose = CCSprite::create("fechar_btn.png");
    CCSprite *btnClosePress = CCSprite::create("fechar_press.png");

    CCSprite *Icone = CCSprite::create("icone_horario.png");
    Icone->setPosition(ccp(45,225));
    node->addChild(Icone);
    
    CCMenuItemSprite *itembtnClose = CCMenuItemSprite::create(btnClose, btnClosePress, node, menu_selector(AlertViewScene::btnCloseAlert));
	itembtnClose->setAnchorPoint(ccp(0, 0));
	itembtnClose->setPosition(ccp(280,303));
    
    //Button Rota para o local
    CCSprite *btnSelect = CCSprite::create("Rota_btn.png");
    CCSprite *btnUnselect = CCSprite::create("Rota_press.png");
    
    CCMenuItemSprite *itembtnRota = CCMenuItemSprite::create( btnSelect,btnUnselect, node,callbackFunction);
	itembtnRota->setAnchorPoint(ccp(0, 0));
	itembtnRota->setPosition(ccp(80,150));
    //Button Rota para o local
    CCMenu* options = CCMenu::create();
    options->addChild(itembtnClose,0,44);
    options->addChild(itembtnRota,0,wayPoint);
    options->setPosition(ccp(0, -20));
    node->addChild(options,3,Global::TAG_Child_Layer);

    //Title of Alert
    CCLabelTTF *labelTitle;
    labelTitle = CCLabelTTF::create(IFixedMenu::LoadWayPointName(wayPoint), "LucidaGrandeBold", 16);
    labelTitle->setPosition(ccp(35, 260));
    labelTitle->setAnchorPoint(ccp(0,0));
    labelTitle->setColor(ccc3(55, 55, 55));
    node->addChild(labelTitle);
    
    CCLabelTTF *labelSubTitle;
    labelSubTitle = CCLabelTTF::create("Horário de funcionamento", "LucidaGrandeBold", 11);
    labelSubTitle->setPosition(ccp(60, 225));
    labelSubTitle->setAnchorPoint(ccp(0,0));
    labelSubTitle->setColor(ccc3(55, 55, 55));
    node->addChild(labelSubTitle);
    
    //Description of Alert
    CCLabelTTF *labelDescription;
    labelDescription = CCLabelTTF::create("Estamos abertos todos os dias das 9h as 24h*", "Lucida Grande", 10);
    labelDescription->setPosition(ccp(60, 210));
    labelDescription->setAnchorPoint(ccp(0,0));
    labelDescription->setColor(ccc3(55, 55, 55));
    node->addChild(labelDescription);
    
    ((CCLayerColor*)sender)->setOpacity(30);
    CCDirector::sharedDirector()->getRunningScene()->addChild(node,10,Global::TAG_Alert_Layer);
}
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;
}
bool CNFServerChangeLayer::InitLayer(int nCurrentServerID,int nServerTotalNum)
{
	do 
	{
		//初始化父类
		CC_BREAK_IF(CCLayer::init()==false);

		m_nCurrentServerID = nCurrentServerID;

		/************************************************************************/
		/*			背景图片                                                                     */
		/************************************************************************/
		//创建背景
		CCSprite * pBg = CCSprite::create("ui/serverselect_bg.png");
		CC_BREAK_IF(pBg==NULL);
		pBg->setPosition(SCREEN_CENTER);
		pBg->setScaleX( (float)CCDirector::sharedDirector()->getWinSize().width/(float)pBg->getContentSize().width );
		addChild(pBg,enZOrderBack);

		//创建上次登录图片
		CCSprite * pBg1 = CCSprite::create("ui/serverselect_title_1.png");
		CC_BREAK_IF(pBg1==NULL);
		pBg1->setPosition(ccp(150+_NF_SCREEN_WIDTH_DIS_,420));
		addChild(pBg1,enZOrderBack);

		//创建全服务器图片
		CCSprite * pBg2 = CCSprite::create("ui/serverselect_title_2.png");
		CC_BREAK_IF(pBg2==NULL);
		pBg2->setPosition(ccp(160+_NF_SCREEN_WIDTH_DIS_,300));
		addChild(pBg2,enZOrderBack);

		/************************************************************************/
		/*			创建按钮                                                                     */
		/************************************************************************/
		CCMenu * pMenu = CCMenu::create();
		CC_BREAK_IF(pMenu==NULL);
		pMenu->setPosition(CCPointZero);
		addChild(pMenu,enZOrderFront);

		//创建返回按钮
		//CCMenuItemSprite * pBtnBack = CCMenuItemSprite::create(
		//	CCSprite::create("ui/serverselect_btn_back_n.png"),
		//	CCSprite::create("ui/serverselect_btn_back_p.png"),
		//	this,
		//	menu_selector(CNFServerChangeLayer::OnBtnCallBack));
		//CC_BREAK_IF(pBtnBack==NULL);
		//pBtnBack->setPosition(ccp(SCREEN_WIDTH - 30,SCREEN_HEIGHT-30));
		//pMenu->addChild(pBtnBack,enZOrderFront);

		//创建当前服务器按钮
		CCMenuItemSprite * pBtnCurrentServer = CCMenuItemSprite::create(
			CCSprite::create("ui/btn_enter_n.png"),
			CCSprite::create("ui/btn_enter_p.png"),
			this,
			menu_selector(CNFServerChangeLayer::OnBtnCallBack));
		CC_BREAK_IF(pBtnCurrentServer==NULL);
		pBtnCurrentServer->setPosition(ccp(190+_NF_SCREEN_WIDTH_DIS_,380));
		pMenu->addChild(pBtnCurrentServer,enZOrderFront);

		//创建左侧按钮
		CCMenuItemSprite * pBtnLeft = CCMenuItemSprite::create(
			CCSprite::create("ui/serverselect_btn_back_n.png"),
			CCSprite::create("ui/serverselect_btn_back_p.png"),
			this,
			menu_selector(CNFServerChangeLayer::OnBtnLeftMove));
		CC_BREAK_IF(pBtnLeft==NULL);
		pBtnLeft->setPosition(ccp(50+_NF_SCREEN_WIDTH_DIS_,150));
		pMenu->addChild(pBtnLeft,enZOrderFront);

		//创建右侧按钮
		CCMenuItemSprite * pBtnRight = CCMenuItemSprite::create(
			CCSprite::create("ui/serverselect_btn_back_n.png"),
			CCSprite::create("ui/serverselect_btn_back_p.png"),
			this,
			menu_selector(CNFServerChangeLayer::OnBtnRightMove));
		CC_BREAK_IF(pBtnRight==NULL);
		pBtnRight->setPosition(ccp(SCREEN_WIDTH-_NF_SCREEN_WIDTH_DIS_-50,150));
		pMenu->addChild(pBtnRight,enZOrderFront);

		/************************************************************************/
		/*				创建label                                                                     */
		/************************************************************************/
		CCDictionary *pDicLang = CCDictionary::createWithContentsOfFile("ui_xml/serverselect_xml.xml");
		CC_BREAK_IF(pDicLang==NULL);

		//服务器名称label
		CCString *pStrServerName = dynamic_cast<CCString*>(pDicLang->objectForKey("server_name"));
		char szName[NAME_LEN] = {0};
		sprintf(szName,pStrServerName->m_sString.c_str(),nCurrentServerID);
		CCLabelTTF * pLabelServerName = CCLabelTTF::create(szName,"Arial",20);
		CC_BREAK_IF(pLabelServerName==NULL);
		pLabelServerName->setPosition(pBtnCurrentServer->getPosition());
		addChild(pLabelServerName,enZOrderFront);


		/************************************************************************/
		/*					创建滑动层                                                                     */
		/************************************************************************/
		//创建滑动层
		CNFServerChangeScrollLayer * pLayer = CNFServerChangeScrollLayer::CreateLayer(nServerTotalNum);	//Item数组,x轴起始位置
		CC_BREAK_IF(pLayer==NULL);
		pLayer->SetMsg(this);
		addChild(pLayer,enZOrderFront,enTagScrollLayer);


		return true;
	} while (false);
	CCLog("Fun CNFServerChangeLayer::init Error!");
	return false;
}