Esempio n. 1
0
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

    CCLog("visible size - x: %f, y: %f",visibleSize.width, visibleSize.height);
    CCLog("origin - x: %f, y: %f", origin.x, origin.y);
    
    //KYULING: 게임 메뉴로 출력할 메뉴 아이템 생성
    CCMenuItemLabel *startLabel = CCMenuItemLabel::create(CCLabelTTF::create("Game start", "Arial", 18), this, menu_selector(HelloWorld::gameStartMenuTapped));
    CCMenuItemLabel *optionLabel = CCMenuItemLabel::create(CCLabelTTF::create("Game Option", "Arial", 18), this, menu_selector(HelloWorld::gameOptionMenuTapped));
    
    //게임 메뉴 생성
    CCMenu *gameMenu = CCMenu::create(startLabel, optionLabel, NULL);
    gameMenu->alignItemsVerticallyWithPadding(20);
    this->addChild(gameMenu);
    
    return true;
}
Esempio n. 2
0
bool MenuLayer::init(GameplayView* view)
{
	bool bRet = false;
	do 
	{
		_parent = view;

		int fontSize = 32;
		CCString* fontName = CCString::create("Thonburi");

		CCMenuItemLabel* resume = CCMenuItemLabel::create(CCLabelTTF::create("Resume", fontName->getCString(), fontSize), this, menu_selector(MenuLayer::resume));
		
		CCMenu* menu = CCMenu::create(resume, NULL);
		menu->alignItemsVerticallyWithPadding(10);
		addChild(menu);

		CCSize winSize = CCDirector::sharedDirector()->getWinSize();
		CCLabelTTF* gameover = CCLabelTTF::create("Game Over", "American Typewriter", 64);
		addChild(gameover);
		gameover->setColor(ccc3(126, 126, 126));
		gameover->setPosition(ccp(winSize.width*0.5,winSize.height*0.5 + 84));

		_scoreLabel = CCLabelTTF::create("60", "American Typewriter", 16);
		addChild(_scoreLabel);
		_scoreLabel->setColor(ccc3(126, 126, 126));
		_scoreLabel->setPosition(ccp(winSize.width*0.5,winSize.height*0.5 + 32));

		bRet = true;
	} while (0);
	return bRet;
}
Esempio n. 3
0
bool Bug458Layer::init()
{
    if(BugsTestBaseLayer::init())
    {
		// ask director the the window size
        CCSize size = CCDirector::sharedDirector()->getWinSize();

        QuestionContainerSprite* question = new QuestionContainerSprite();
        QuestionContainerSprite* question2 = new QuestionContainerSprite();
        question->init();
        question2->init();

//		[question setContentSize:CGSizeMake(50,50)];
//		[question2 setContentSize:CGSizeMake(50,50)];
		
        CCMenuItemSprite* sprite = CCMenuItemSprite::itemFromNormalSprite(question2, question, this, menu_selector(Bug458Layer::selectAnswer));
        CCLayerColor* layer = CCLayerColor::layerWithColorWidthHeight(ccc4f(0,0,255,255), 100, 100);
		question->release();
		question2->release();

        CCLayerColor* layer2 = CCLayerColor::layerWithColorWidthHeight(ccc4f(255,0,0,255), 100, 100);
        CCMenuItemSprite* sprite2 = CCMenuItemSprite::itemFromNormalSprite(layer, layer2, this, menu_selector(Bug458Layer::selectAnswer));        
        CCMenu* menu = CCMenu::menuWithItems(sprite, sprite2, NULL);
        menu->alignItemsVerticallyWithPadding(100);
        menu->setPosition(ccp(size.width / 2, size.height / 2));

		// add the label as a child to this Layer
		addChild(menu);

        return true;
	}
	return false;
}
Esempio n. 4
0
// on "init" you need to initialize your instance
bool HelpScene::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
    
    CCSprite *background = CCSprite::create("title_help.png");
    background->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.5f));
    this->addChild(background);
    
    CCMenuItemImage *backButton = CCMenuItemImage::create("back_button.png", "back_button.png", this, menu_selector(HelpScene::BackPressed));
    
    CCMenu *mainMenu = CCMenu::create(backButton, NULL);
    mainMenu->alignItemsVerticallyWithPadding(screenSize.height * 0.03f);
    mainMenu->setPosition(ccp(screenSize.width * 0.75f, screenSize.height * 0.1f));
    
    this->addChild(mainMenu);
    
    return true;
}
bool GameOverLayer::init()
{
	if ( CCLayerColor::initWithColor( ccc4(255,255,255,255) ) )
	{
		// Get window size and place the label upper. 
		CCSize size = CCDirector::sharedDirector()->getWinSize();

		// 3. Add add a splash screen, show the cocos2d splash image.
		CCSprite* pSprite = CCSprite::create("IntroScene.png");
		if(!pSprite)
			return false;

		// Place the sprite on the center of the screen
		pSprite->setPosition(ccp(size.width/2, size.height/2));

		// Add the sprite to HelloWorld layer as a child layer.
		this->addChild(pSprite, 0);

		//Add the menu choice
		CCMenuItemFont::setFontSize( 100 );
		CCMenuItemFont::setFontName("Courier New");
		CCLabelBMFont* labelNew = CCLabelBMFont::create("Restart Game!", "bitmapFontTest3.fnt");
		CCMenuItemLabel* itemNew = CCMenuItemLabel::create(labelNew, this, menu_selector(GameOverLayer::menuRestartCallback));

		CCLabelBMFont* labelQuit = CCLabelBMFont::create("Quit", "bitmapFontTest3.fnt");
		CCMenuItemLabel* itemQuit = CCMenuItemLabel::create(labelQuit, this, menu_selector(GameOverLayer::menuCloseCallback));

		CCMenu* menu = CCMenu::create( itemNew, itemQuit, NULL);
		menu->alignItemsVerticallyWithPadding(50);

		int i=0;
		CCNode* child;
		CCArray * pArray = menu->getChildren();
		CCObject* pObject = NULL;
		CCARRAY_FOREACH(pArray, pObject)
		{
			if(pObject == NULL)
				break;

			child = (CCNode*)pObject;

			CCPoint dstPoint = child->getPosition();
			int offset = (int) (size.width/2 + 50);
			if( i % 2 == 0)
				offset = -offset;

			child->setPosition( ccp( dstPoint.x + offset, dstPoint.y) );
			child->runAction( 
				CCEaseElasticOut::create(CCMoveBy::create(2, ccp(dstPoint.x - offset,0)), 0.35f) 
				);
			i++;
		}

		addChild(menu);
		menu->setPosition(ccp(size.width/2, size.height/2));

		EntityManager::GetInstance()->SetGameOver(false);

		return true;
	}
KDbool OverScene::init ( KDvoid )
{
	if ( !CCLayer::init ( ) )
	{
		return KD_FALSE;
	}

	CCMenuItemFont::setFontSize ( 32 );
	CCMenuItemFont::setFontName ( "Arial.ttf" );

	CCLayerColor*	pLayer = CCLayerColor::create ( ccc4 ( 32, 32, 32, 255 ) );
	this->addChild ( pLayer, 1 ); 

	m_pTopScore = CCLabelTTF::create ( "0", "Arial.ttf", 32 );
	this->addChild ( m_pTopScore, 3 );
	m_pTopScore->setColor ( ccc3 ( 255, 0, 0 ) );
	m_pTopScore->setPosition ( ccp ( 160, 370 - 50 ) );	

	m_pScore = CCLabelTTF::create ( "0", "Arial.ttf", 32 );
	this->addChild ( m_pScore, 3 );
	m_pScore->setColor ( ccc3 ( 0, 0, 255 ) );
	m_pScore->setPosition ( ccp ( 160, 320 - 40 ) );	

	CCMenuItemFont*		pReStart = CCMenuItemFont::create ( "RESTART", this, menu_selector ( OverScene::onReStart ) );
	pReStart->setColor ( ccc3 ( 0x00, 0xCC, 0x00 ) );

	CCMenu*				pMenu = CCMenu::create ( pReStart, KD_NULL );	
	pMenu->setPosition ( ccpMid ( m_tContentSize ) );
	pMenu->alignItemsVerticallyWithPadding ( 20.0f );
	this->addChild ( pMenu, 2 );

	return KD_TRUE;
}
Esempio n. 7
0
bool LayerMainMenu::initLayer()
{
	bool bRet = false;

	do
	{
		CCMenuItemFont *pPlayItem = CCMenuItemFont::create( LuaHelper::s_getStringVar("TEXT_PLAY").c_str(), this, menu_selector(LayerMainMenu::onPlay));
		CC_BREAK_IF(! pPlayItem);

		CCMenuItemFont *pQuitItem = CCMenuItemFont::create( LuaHelper::s_getStringVar("TEXT_QUIT").c_str(), this, menu_selector(LayerMainMenu::onQuit));
		CC_BREAK_IF(! pQuitItem);

		CCMenu* pMenu = CCMenu::create( pPlayItem, pQuitItem, NULL );
		CC_BREAK_IF(! pMenu);
		pMenu->alignItemsVerticallyWithPadding( 100.0f );

		addChild( pMenu );

		CCSize s = CCDirector::sharedDirector()->getWinSize();
		pMenu->setPosition(ccp(s.width/2, s.height/2));

		setKeypadEnabled(true);

		bRet = true;
	}
	while( false );

	return bRet;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }

    CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
    
    CCSprite *background = CCSprite::create("MainMenuBackground.png");
    background->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.5f));
    this->addChild(background);
    
    CCMenuItemImage *playButton = CCMenuItemImage::create("PlayButton.png", "PlayButton.png", this, menu_selector(HelloWorld::PlayPressed));
    
    CCMenuItemImage *helpButton = CCMenuItemImage::create("HelpButton.png", "HelpButton.png", this, menu_selector(HelloWorld::HelpPressed));
    
    CCMenu *mainMenu = CCMenu::create(playButton, helpButton, NULL);
    mainMenu->alignItemsVerticallyWithPadding(screenSize.height * 0.03f);
    mainMenu->setPosition(ccp(screenSize.width * 0.5f, screenSize.height * 0.3f));
    
    this->addChild(mainMenu);
    
    SimpleAudioEngine::sharedEngine()->playBackgroundMusic("mainMenuMusic.mp3", true);
    
    return true;
}
Esempio n. 9
0
bool TitleLayer::init()
{
	if ( !CCLayer::init() )
	{
		return false;
	}
    
    // Get window size
    CCSize windowSize = CCDirector::sharedDirector()->getWinSize();

	/* BackGround image */
	CCSprite *backImage = CCSprite::spriteWithFile("menu/bg_darkwood_3_logo.jpg");
    backImage->setPosition(ccp(windowSize.width/2, windowSize.height/2));
    this->addChild(backImage);
    //this->setIsTouchEnabled(true);

	/* Title */
	//CCSprite *titleImage = CCSprite::spriteWithFile("menu/title.png");
	
	//titleImage->setPosition(ccp(windowSize.width/2, windowSize.height - 50)); // 50 - title height
    //this->addChild(titleImage, 1);
    

	/* Menu */
    // Create "play," "scores," and "controls" buttons - when tapped, they call methods we define: playButtonAction and scoresButtonAction
	CCSprite *newGameSprite = CCSprite::spriteWithFile("menu/new_game.png");
	CCMenuItemSprite *newGameButton = CCMenuItemSprite::itemWithNormalSprite(newGameSprite, newGameSprite, newGameSprite, this, menu_selector(TitleLayer::newGameAction));

	CCSprite *creditsSprite = CCSprite::spriteWithFile("menu/credits.png");
	CCMenuItemSprite *creditsButton = CCMenuItemSprite::itemWithNormalSprite(creditsSprite, creditsSprite, creditsSprite,
		this, menu_selector(TitleLayer::creditsAction));

   
	CCMenu *menu = CCMenu::menuWithItems(newGameButton, creditsButton, NULL);
	menu->alignItemsVerticallyWithPadding(20);
    
	// Set position of menu to be below the title text
    menu->setPosition(ccp(windowSize.width / 2, 100));

    // Add menu to layer
    this->addChild(menu, 2);
        

	/* testing */
	/*Letter *letter = new Letter("W");
	letter->setPosition(ccp(windowSize.width - 50, windowSize.height - 50));
	letter->runAction(CCRotateBy::create(10, 360));
	this->addChild(letter);*/

	//Word *word = new Word("WORDS");
	//word->appendLetter('!');
	//this->addChild(word);

	//word->alignLettersHorizontallyWithPadding(42);
	//word->setPosition(ccp(windowSize.width/2, windowSize.height - 50));
	//word->randomlyRotateLetters();
	
	return true;
}
void GameClearPopup::makeLabels()
{
    //背景
    CCSprite* frame = CCSprite::createWithSpriteFrameName(PNG_POPUP_BG2);
    frame->setScale(2.5f);
    frame->setPosition(GHelper::convI720toCC(g_visibleSize.width / 2, g_visibleSize.height / 2));
    this->addChild(frame);

    //タイトル
    CCString *s = NULL;
    if (UserSettings::getSelectedLevel() >= 15) {
    	s = CCString::create("All Clear!");
	} else {
		s = CCString::create("You Win!");
	}
    CCLabelBMFont* title = CCLabelBMFont::create(s->getCString(), FONT_YELLOW);
    title->setScale(0.6);
    title->setPosition( GHelper::convI720toCC(g_visibleSize.width * 0.5, g_visibleSize.height * 0.3));
    this->addChild(title);

    //女の子
    CCSprite *obj = CCSprite::createWithSpriteFrameName(PNG_MINI2_1);
    obj->setPosition(GHelper::convI720toCC(g_visibleSize.width * 0.5, g_visibleSize.height * 0.35));
    obj->runAction(Animations::winMiniAnimation());
    this->addChild(obj);

    //Next Stage?
    if (UserSettings::getSelectedLevel() >= 15) {
    	s = CCString::create("");
	} else {
		s = CCString::create("Next Stage?");
	}
    CCLabelBMFont* disc1 = CCLabelBMFont::create(s->getCString(), FONT_GREEN);
    disc1->setScale(0.5);
    CCMenuItemLabel* item1 = CCMenuItemLabel::create(disc1, this, menu_selector(GameClearPopup::onTapNextStage));

    //Again?
    CCLabelBMFont* disc2 = CCLabelBMFont::create("Again?", FONT_WHITE);
    disc2->setScale(0.5);
    CCMenuItemLabel* item2 = CCMenuItemLabel::create(disc2, this, menu_selector(GameClearPopup::onTapAgain));

    //Menu
    CCLabelBMFont* disc3 = CCLabelBMFont::create("Menu", FONT_WHITE);
    disc3->setScale(0.5);
    CCMenuItemLabel* item3 = CCMenuItemLabel::create(disc3, this, menu_selector(GameClearPopup::onTapMenu));

    //Quit
    CCLabelBMFont* disc4 = CCLabelBMFont::create("Quit", FONT_WHITE);
    disc4->setScale(0.5);
    CCMenuItemLabel* item4 = CCMenuItemLabel::create(disc4, this, menu_selector(GameClearPopup::onTapQuit));

    CCMenu* menu = CCMenu::create( item1, item2, item3, item4, NULL );
    menu->setTouchPriority(-128);
    menu->alignItemsVerticallyWithPadding(1.0);
    menu->setPosition(ccp(g_visibleSize.width / 1.5, g_visibleSize.height / 2 - 50));
    this->addChild(menu);
}
Esempio n. 11
0
// Initialize the menu items, background, and overall setup of the main menu
//
// return - false if there was an error in initializing, true otherwise
bool MainMenu::init()
{
    CCLabelTTF*      labelSinglePlayer; // the text for single player menu item
    CCLabelTTF*      labelMultiplayer;  // the text for multiplayer menu item
    CCLabelTTF*      labelOptions;      // the text for options menu item
    CCMenuItemLabel* itemSinglePlayer;  // menu item for starting single player game
    CCMenuItemLabel* itemMultiplayer;   // menu item for starting multiplayer game
    CCMenuItemLabel* itemOptions;       // menu item for opening up options
    CCMenu*          menu;              // menu to contain the menu items

    CCSize           size;              // the size of the window
    CCSprite*        background;        // the background splashscreen

    if(!CCLayer::init())
    {
        return false;
    }

    // get the window size from the director
    size = CCDirector::sharedDirector()->getWinSize();

    // create the text for the menu items
    labelSinglePlayer = CCLabelTTF::create("Start Single Player", FONT_STYLE, Font_Size_Default);
    labelMultiplayer  = CCLabelTTF::create("Start Multiplayer", FONT_STYLE, Font_Size_Default);
    labelOptions      = CCLabelTTF::create("Options", FONT_STYLE, Font_Size_Default);

    // add shadows to the labels, so they will be easier to read against the background
    labelSinglePlayer->enableShadow(FONT_SHADOW_OFFSET, FONT_SHADOW_OPACITY, FONT_SHADOW_BLUR);
    labelMultiplayer->enableShadow(FONT_SHADOW_OFFSET, FONT_SHADOW_OPACITY, FONT_SHADOW_BLUR);
    labelOptions->enableShadow(FONT_SHADOW_OFFSET, FONT_SHADOW_OPACITY, FONT_SHADOW_BLUR);

    // create the items for the menu
    itemSinglePlayer = CCMenuItemLabel::create(labelSinglePlayer, this, menu_selector(MainMenu::HandleSinglePlayerPressed));
    itemMultiplayer  = CCMenuItemLabel::create(labelMultiplayer, this, menu_selector(MainMenu::HandleMultiplayerPressed));
    itemOptions      = CCMenuItemLabel::create(labelOptions, this, menu_selector(MainMenu::HandleOptionsPressed));

    // set the color of the menu items
    itemSinglePlayer->setColor(MENU_COLOR);
    itemMultiplayer->setColor(MENU_COLOR);
    itemOptions->setColor(MENU_COLOR);

    // create menu to contain the menu items
    menu = CCMenu::create(itemSinglePlayer, itemMultiplayer, itemOptions, NULL);
    menu->alignItemsVerticallyWithPadding(MENU_ITEM_PADDING);
    menu->setPosition(size.width * POS_HALF_SCREEN, size.height * POS_HALF_SCREEN);
    addChild(menu, 1);

    // add splash screen as a sprite on the center of the screen
    background = CCSprite::create(BACKGROUND_IMAGE);
    background->setScale(size.height / background->boundingBox().size.height);
    background->setPosition( ccp(size.width * POS_HALF_SCREEN, size.height * POS_HALF_SCREEN) );
    addChild(background, 0);

    return true;
}
bool InterfaceRenderer::init() {
    if( !CCLayer::init() )
        return false;
    
    CCSize designResolutionSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize();
    
    CCLabelTTF* label = CCLabelTTF::create("분당우리교회 청년2부 행복나무", "Arial", 100);
    label->setAnchorPoint(ccp(0.5f, 1));
    label->setPosition(ccp(designResolutionSize.width/2, designResolutionSize.height-label->getDimensions().height));
    this->addChild(label);
    
//    {
//        editbox = CCEditBox::create(CCSizeMake(800, 100), CCScale9Sprite::create("green_edit.png"));
//        editbox->retain();
//        editbox->setPosition(ccp(designResolutionSize.width/2, 10));
//        editbox->setAnchorPoint(ccp(0.5f, 0));
//        editbox->setPlaceHolder("테스트용 단어를 입력해주세요.");
//        editbox->setFont("Arial", 60);
//        editbox->setFontColor(ccBLACK);
//        this->addChild(editbox);
//    }
    
    CCMenuItemFont::setFontSize(80);
    CCMenuItemFont::setFontName("Arial");
 
    // for test button
//    {
//        CCMenuItemFont* item = CCMenuItemFont::create("Add", this, menu_selector(InterfaceRenderer::onTouchedDone));
//        item->setAnchorPoint(ccp(0, 0));
//        item->setPosition(ccp(editbox->getContentSize().width+10, 0));
//        
//        CCMenuItemFont* printItem = CCMenuItemFont::create("Print", this, menu_selector(InterfaceRenderer::onTouchedPrint));
//        printItem->setAnchorPoint(ccp(0, 0));
//        printItem->setPosition(ccp(editbox->getContentSize().width+10*2+item->boundingBox().size.width, 0));
//        
//        CCMenu* menu = CCMenu::create(item,printItem,NULL);
//        menu->setPosition(ccp(0, 0));
//        menu->setAnchorPoint(ccp(0, 0));
//        editbox->addChild(menu);
//    }
    
    
    // for menually refresh button
    {
        CCMenuItemFont* item1 = CCMenuItemFont::create("requestWord", this, menu_selector(InterfaceRenderer::onTouchedRequestWord));
        CCMenuItemFont* item2 = CCMenuItemFont::create("requestMistake", this, menu_selector(InterfaceRenderer::onTouchedRequestMistake));
        
        CCMenu* menu = CCMenu::create(item1, item2, NULL);
        menu->alignItemsVerticallyWithPadding(10);
        this->addChild(menu);
    }
    
    return true;
}
Esempio n. 13
0
CCMenu* StadionLayer::createStadionMenu()
{
    CCMenuItemSprite* pause = sgl_SpriteFactory.createMenuItemSprite("btnPause.png", "btnPausePressed.png",menu_selector(StadionLayer::onPause), this);
    CCMenuItemSprite* help = sgl_SpriteFactory.createMenuItemSprite("btnHelp.png", "btnHelp.png",menu_selector(StadionLayer::onHelp), this);
    
    CCMenu* menu = CCMenu::create(pause, help, NULL);
    
    menu->alignItemsVerticallyWithPadding(2);
    menu->setPosition(ccp(32,60));
    
    return menu;
}
Esempio n. 14
0
//------------------------------------------------------------------
//
// LabelTTFTest
//
//------------------------------------------------------------------
LabelTTFTest::LabelTTFTest()
{
    CCSize blockSize = CCSizeMake(200, 160);
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCLayerColor *colorLayer = CCLayerColor::create(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height);
    colorLayer->setAnchorPoint(ccp(0,0));
    colorLayer->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2));

    this->addChild(colorLayer);

    CCMenuItemFont::setFontSize(30);
    CCMenu *menu = CCMenu::create(
        CCMenuItemFont::create("Left", this, menu_selector(LabelTTFTest::setAlignmentLeft)),
        CCMenuItemFont::create("Center", this, menu_selector(LabelTTFTest::setAlignmentCenter)),
        CCMenuItemFont::create("Right", this, menu_selector(LabelTTFTest::setAlignmentRight)),
        NULL);
    menu->alignItemsVerticallyWithPadding(4);
    menu->setPosition(ccp(50, s.height / 2 - 20));
    this->addChild(menu);

    menu = CCMenu::create(
        CCMenuItemFont::create("Top", this, menu_selector(LabelTTFTest::setAlignmentTop)),
        CCMenuItemFont::create("Middle", this, menu_selector(LabelTTFTest::setAlignmentMiddle)),
        CCMenuItemFont::create("Bottom", this, menu_selector(LabelTTFTest::setAlignmentBottom)),
        NULL);
    menu->alignItemsVerticallyWithPadding(4);
    menu->setPosition(ccp(s.width - 50, s.height / 2 - 20));
    this->addChild(menu);

    m_plabel = NULL;
    m_eHorizAlign = kCCTextAlignmentLeft;
    m_eVertAlign = kCCVerticalTextAlignmentTop;

    this->updateAlignment();
}
Esempio n. 15
0
bool MainMenuBtnLayer::init()
{
    bool bRet = false;
    do
    {
        // Super init first
        CC_BREAK_IF(!CCLayer::init());

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


        CCImage menufile;
        menufile.initWithImageFile("Buttons.png");
        CCTexture2D *menuTexture = new CCTexture2D();
        menuTexture->initWithImage(&menufile);

        CCMenuItemSprite *startgameitem = CCMenuItemSprite::create(CCSprite::createWithTexture(menuTexture, CCRectMake(6, 2, 166, 28)),
                                          CCSprite::createWithTexture(menuTexture, CCRectMake(6, 35, 166, 28)),
                                          CCSprite::createWithTexture(menuTexture, CCRectMake(6, 70, 166, 28)),
                                          this, menu_selector (MainMenuBtnLayer::menucallback));
        startgameitem->setTag(MAINMENU_ID_START);
        CCMenuItemSprite *settings = CCMenuItemSprite::create(CCSprite::createWithTexture(menuTexture, CCRectMake(188, 2, 166, 28)),
                                     CCSprite::createWithTexture(menuTexture, CCRectMake(188, 35, 166, 28)),
                                     CCSprite::createWithTexture(menuTexture, CCRectMake(188, 70, 166, 28)),
                                     this, menu_selector (MainMenuBtnLayer::menucallback));
        settings->setTag(MAINMENU_ID_SETTING);
        CCMenuItemSprite *about = CCMenuItemSprite::create(CCSprite::createWithTexture(menuTexture, CCRectMake(370, 2, 166, 28)),
                                  CCSprite::createWithTexture(menuTexture, CCRectMake(370, 35, 166, 28)),
                                  CCSprite::createWithTexture(menuTexture, CCRectMake(370, 70, 166, 28)),
                                  this, menu_selector (MainMenuBtnLayer::menucallback));
        about->setTag(MAINMENU_ID_ABOUT);
        CCMenuItemSprite *quit = CCMenuItemSprite::create(CCSprite::createWithTexture(menuTexture, CCRectMake(552, 2, 166, 28)),
                                 CCSprite::createWithTexture(menuTexture, CCRectMake(552, 35, 166, 28)),
                                 CCSprite::createWithTexture(menuTexture, CCRectMake(552, 70, 166, 28)),
                                 this, menu_selector (MainMenuBtnLayer::menucallback));
        quit->setTag(MAINMENU_ID_QUIT);

        CCMenu *menu = CCMenu::create(startgameitem, settings, about, quit, NULL);
        menu->alignItemsVerticallyWithPadding(10);
        menu->setPosition(ccp(size.width * 0.5f, size.height * 0.5f));
        this->addChild(menu);

        bRet = true;

    } while(0);

    return bRet;
}
Esempio n. 16
0
// on "init" you need to initialize your instance
bool StartMenu::init()
{
    bool bRet = false;
    do 
    {
        CC_BREAK_IF(! CCLayer::init());

		CCSize winSize = CCDirector::sharedDirector()->getWinSize();
		
		CCSprite *background = CCSprite::create(s_bg);
		background->setPosition(ccp(winSize.width / 2, winSize.height / 2));
		addChild(background, 0);

		CCSprite* newGameNormal = CCSprite::create(s_play);
		CCSprite* newGameSelected = CCSprite::create(s_play);
		CCSprite* newGameDisabled = CCSprite::create(s_play);

		CCSprite* gameSettingNormal = CCSprite::create(s_option);
		CCSprite* gameSettingNSelected = CCSprite::create(s_option);
		CCSprite* gameSettingDesabled = CCSprite::create(s_option);

		CCSprite* exitNormal = CCSprite::create(s_exit);
		CCSprite* exitSelected = CCSprite::create(s_exit);
		CCSprite* exitDesabled = CCSprite::create(s_exit);

		CCMenuItemSprite* newGame = CCMenuItemSprite::create(newGameNormal, newGameSelected, newGameDisabled, this, menu_selector(StartMenu::menuCallback));
		CCMenuItemSprite* gameSetting = CCMenuItemSprite::create(gameSettingNormal, gameSettingNSelected, gameSettingDesabled, this, menu_selector(StartMenu::menuCallback));
		CCMenuItemSprite* exit = CCMenuItemSprite::create(exitNormal, exitSelected, exitDesabled, this, menu_selector(StartMenu::menuCallback));

		newGame->setTag(0);
		gameSetting->setTag(1);
		exit->setTag(2);

		CCMenu* menu = CCMenu::create(newGame, gameSetting, exit, NULL);
		menu->alignItemsVerticallyWithPadding(20);
		this->addChild(menu);
		menu->setPosition(ccp(winSize.width / 2, winSize.height / 2));
		//this->schedule(schedule_selector(StartMenu::update), 0.1);


		bRet = true;
    } while (0);

    return bRet;
}
Esempio n. 17
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;
}
Esempio n. 18
0
bool GameSceneMainLayer::init()
{
    if (!CCLayer::init()) {
        return false;
    }

    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
 
    mGameLayer = GameScene::create();
    this->addChild(mGameLayer);

    mStatusLayer = StatusLayer::create();
    mStatusLayer->setPosition(ccp(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2));
    mStatusLayer->setVisible(false);
    this->addChild(mStatusLayer, 100);

    /*
    CCMenuItemFont* pStatus = CCMenuItemFont::create("Status", this, menu_selector(GameSceneMainLayer::onMenuStatus));
    CCMenuItemFont* pMagic  = CCMenuItemFont::create("Magic", this, menu_selector(GameSceneMainLayer::onMenuMagic));
    CCMenuItemFont* pZoomIn = CCMenuItemFont::create("ZoomIn", this, menu_selector(GameSceneMainLayer::onZoomIn));
    CCMenuItemFont* pZoomOut= CCMenuItemFont::create("ZoomOut", this, menu_selector(GameSceneMainLayer::onZoomOut));

    CCMenu* menu = CCMenu::create(pStatus, pMagic, pZoomIn, pZoomOut, NULL);
    menu->alignItemsHorizontally();
    menu->setPosition(ccp(origin.x + visibleSize.width / 2, origin.y + 32));
    this->addChild(menu, 200);
    */

    pMove = CCMenuItemImage::create("icons/move.png", "icons/move.png", this, menu_selector(GameSceneMainLayer::onMenuMove));
    pAttack = CCMenuItemImage::create("icons/attack.png", "icons/attack.png", this, menu_selector(GameSceneMainLayer::onMenuAttack));
    pExamine = CCMenuItemImage::create("icons/examine.png", "icons/examine.png", this, menu_selector(GameSceneMainLayer::onMenuExamine));
    pMagic = CCMenuItemImage::create("icons/magic.png", "icons/magic.png", this, menu_selector(GameSceneMainLayer::onMenuMagic));
    pStatus = CCMenuItemImage::create("icons/status.png", "icons/status.png", this, menu_selector(GameSceneMainLayer::onMenuStatus));
    pHero = CCMenuItemImage::create("icons/hero.png", "icons/hero.png", this, menu_selector(GameSceneMainLayer::onMenuHero));
    pTurn = CCMenuItemImage::create("icons/turn.png", "icons/turn.png", this, menu_selector(GameSceneMainLayer::onMenuTurn));
    CCMenu* menu = CCMenu::create(pMove, pAttack, pExamine, pMagic, pStatus, pHero, pTurn, NULL);
    menu->alignItemsVerticallyWithPadding(5);
    menu->setPosition(ccp(origin.x + visibleSize.width - pMove->getContentSize().width / 2 , origin.y + visibleSize.height / 2));
    this->addChild(menu, 200);

    pMove->setScale(1.5f);
    return true;
}
Esempio n. 19
0
bool MainMenu::init()
{
    //super init
    if (!CCLayer::init()) {
        return false;
    }

//    CCSize size = CCDirector::sharedDirector()->getWinSize();
    // CCMenuItem
    CCMenuItemImage *imageItemStart=CCMenuItemImage::create("restart_btn.png", "restart_btn.png",this,menu_selector(MainMenu::menu_game_start));
    imageItemStart->setPosition(CCPointZero);
    CCMenuItemImage *imageItemSet=CCMenuItemImage::create("restart_btn.png", "restart_btn.png",this,menu_selector(MainMenu::menu_game_seting));
    CCMenuItemImage *imageItemExit=CCMenuItemImage::create("restart_btn.png", "restart_btn.png",this,menu_selector(MainMenu::menu_game_exit));
    CCMenu *menu = CCMenu::create(imageItemStart,imageItemSet,imageItemExit,NULL);
    menu->alignItemsVerticallyWithPadding(40.0);
    this->addChild(menu,2);

    return true;
}
Esempio n. 20
0
void MenuLayer2::alignMenusV()
{
	for(int i=0;i<2;i++) 
	{
		CCMenu *menu = (CCMenu*)getChildByTag(100+i);
		menu->setPosition( m_centeredMenu );
		if(i==0) 
		{
			// TIP: if no padding, padding = 5
			menu->alignItemsVertically();			
			CGPoint p = menu->getPosition();
			menu->setPosition( ccpAdd(p, CGPointMake(100,0)) );			
		} 
		else 
		{
			// TIP: but padding is configurable
			menu->alignItemsVerticallyWithPadding(40);	
			CGPoint p = menu->getPosition();
			menu->setPosition( ccpSub(p, CGPointMake(100,0)) );
		}		
	}
}
Esempio n. 21
0
cocos2d::CCMenu*  BYGameScene::createPauseMenu() { /// creates autorelease object
    CCMenuItemFont* continueItem = CCMenuItemFont::create("Continue",
                                                          this,
                                                          menu_selector(BYGameScene::continueGame));
    continueItem->setTag(GUI_PauseMenu_Continue);
    
    CCMenuItemFont* reItem = CCMenuItemFont::create("Restart",
                                                    this,
                                                    menu_selector(BYGameScene::resetGame));
    CCMenuItemFont* quitItem = CCMenuItemFont::create("Quit",
                                                      this,
                                                      menu_selector(BYGameScene::quitGame));
    
    CCMenu* menu = CCMenu::create(continueItem, reItem, quitItem, NULL);
    menu->alignItemsVerticallyWithPadding(5);
    
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    menu->setPosition(CCPointMake(s.width / 2, s.height / 2));
    menu->setTag(GUI_PauseMenu);
    
    return menu;
}
Esempio n. 22
0
void MenuLayer::createMenu()
{
    int fontSize = 32;
    CCString* fontName = CCString::create("Thonburi");
    
    CCMenuItemLabel* resume = CCMenuItemLabel::create(CCLabelTTF::create("Resume", fontName->getCString(), fontSize), this, menu_selector(MenuLayer::resume));
    
    CCMenuItemLabel* mainMenu = CCMenuItemLabel::create(CCLabelTTF::create("Main Menu", fontName->getCString(), fontSize), this, menu_selector(MenuLayer::mainMenu));
    
    CCMenuItemLabel* soundOn = CCMenuItemLabel::create(CCLabelTTF::create("Sound On", fontName->getCString(), fontSize));
    CCMenuItemLabel* soundOff = CCMenuItemLabel::create(CCLabelTTF::create("Sound Off", fontName->getCString(), fontSize));
    _sound = CCMenuItemToggle::createWithTarget(this, menu_selector(MenuLayer::sound), soundOff, soundOn, NULL);
    
    CCMenuItemLabel* musicOn = CCMenuItemLabel::create(CCLabelTTF::create("Music On", fontName->getCString(), fontSize));
    CCMenuItemLabel* musicOff = CCMenuItemLabel::create(CCLabelTTF::create("Music Off", fontName->getCString(), fontSize));
    _music = CCMenuItemToggle::createWithTarget(this, menu_selector(MenuLayer::music), musicOff, musicOn, NULL);
    
    CCMenuItemLabel* reset = CCMenuItemLabel::create(CCLabelTTF::create("Reset", fontName->getCString(), fontSize), this, menu_selector(MenuLayer::reset));
    
    CCMenu* menu = CCMenu::create(resume, mainMenu, _sound, _music, reset, NULL);
    menu->alignItemsVerticallyWithPadding(10);
    this->addChild(menu);
}
bool MainMenuCtrlLayer::init()
{
    bool ret = false;
    
    do {
        CC_BREAK_IF(!CCLayer::init());
        
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        
        // 菜单
        // 菜单纹理
        CCImage menuImage;
        menuImage.initWithImageFile("menu.png");
        CCTexture2D *menuTexture = new CCTexture2D();
        menuTexture->initWithImage(&menuImage);
        
        // 菜单选项
        CCMenuItemSprite *newGameMenuItem = CCMenuItemSprite::itemFromNormalSprite(CCSprite::spriteWithTexture(menuTexture, CCRectMake(0, 0, 126, 33)), CCSprite::spriteWithTexture(menuTexture, CCRectMake(0, 33, 126, 33)), CCSprite::spriteWithTexture(menuTexture, CCRectMake(0, 33 * 2, 126, 33)), this, menu_selector(MainMenuCtrlLayer::mainMenuCallback));
        newGameMenuItem->setTag(MAINMENU_ID_NEW_GAME);
        
        CCMenuItemSprite *settingMenuItem = CCMenuItemSprite::itemFromNormalSprite(CCSprite::spriteWithTexture(menuTexture, CCRectMake(126, 0, 126, 33)), CCSprite::spriteWithTexture(menuTexture, CCRectMake(126, 33, 126, 33)), CCSprite::spriteWithTexture(menuTexture, CCRectMake(126, 33 * 2, 126, 33)), this, menu_selector(MainMenuCtrlLayer::mainMenuCallback));
        settingMenuItem->setTag(MAINMENU_ID_SETTING);
        
        CCMenuItemSprite *aboutMenuItem = CCMenuItemSprite::itemFromNormalSprite(CCSprite::spriteWithTexture(menuTexture, CCRectMake(252, 0, 126, 33)), CCSprite::spriteWithTexture(menuTexture, CCRectMake(252, 33, 126, 33)), CCSprite::spriteWithTexture(menuTexture, CCRectMake(252, 33 * 2, 126, 33)), this, menu_selector(MainMenuCtrlLayer::mainMenuCallback));
        aboutMenuItem->setTag(MAINMENU_ID_ABOUT);
        
        CCMenu *mainMenu = CCMenu::menuWithItems(newGameMenuItem, settingMenuItem, aboutMenuItem, NULL);
        mainMenu->alignItemsVerticallyWithPadding(10);
        mainMenu->setPosition(ccp(winSize.width / 2, winSize.height / 2 - 80));
        this->addChild(mainMenu);
        
        ret = true;
    } while (0);
    
    return ret;
}
Esempio n. 24
0
bool Settings::init()
{
    if ( !SceneStyle::init() )
    {
        return false;
    }

    //To trigger back button
    this->setKeypadEnabled(true);

    //Get the size of the screen we can see
    CCSize VISIBLE_SIZE = ADScreen::getVisibleSize();

    //Get the screen start of cordinates
    CCPoint ORIGIN = ADScreen::getOrigin();
    float SCALE = ADScreen::getScaleFactor();
    float x_middle_of_sheet = (VISIBLE_SIZE.width-133/SCALE)/2 + ORIGIN.x;


    /////////////////////////////////////////////////////

    //set scene title
    _settings_scene_title = CCLabelTTF::create(_("settings_menu.scene.title"),
                                           ADLanguage::getFontName(),
                                           GameInfo::SIZE_MENU_TITLE);
    _settings_scene_title->setColor(GameInfo::COLOR_DARK_BLUE);
    _settings_scene_title->setAnchorPoint(ccp(0.5,1));
    CCPoint settings_scene_title_target_position = ccp(x_middle_of_sheet,
                                       VISIBLE_SIZE.height + ORIGIN.y - 50/SCALE);
    _settings_scene_title->setPosition(settings_scene_title_target_position);

    //make slowly come to the screen
    _settings_scene_title->setOpacity(0);
    CCFadeTo* settings_scene_title_fade_in = CCFadeTo::create(0.2f, 255);
    _settings_scene_title->runAction(settings_scene_title_fade_in);
    this->addChild(_settings_scene_title);

    ////////////////////////////////////////////////////////

    //create menu for items
    CCMenu* menu = CCMenu::create();
    CCMenu* menu_new = CCMenu::create();
    _menu_item.reserve(6);


    if(GameInfo::isExpertModeAvaliable())
    {
        ADMenuItem* expert_mode = createToggleButton(
                    "settings/Expert_mode_on.png",
                    "settings/Expert_mode_off.png",
                    !_expert_mode_on);
        expert_mode->setClickAction([expert_mode, this](){
            this->onExpertModeSelect(expert_mode);
        });
        _menu_item.push_back(expert_mode);
    }
    else
    {
        _menu_item.push_back(nullptr);
    }

    ADMenuItem* sound = createToggleButton(
                "settings/Sound_on.png",
                "settings/Sound_off.png",
                !ADSoundManager::isSoundTurnedOn());
    sound->setClickAction([sound, this](){
        this->onSoundSelect(sound);
    });
    _menu_item.push_back(sound);


    ADMenuItem* music = createToggleButton(
                "settings/Music_on.png",
                "settings/Music_off.png",
                !ADSoundManager::isMusicTurnedOn());
    music->setClickAction([music, this](){
        this->onMusicSelect(music);
    });
    _menu_item.push_back(music);



    if(GameInfo::isExpertModeAvaliable())
    {
        menu_new->addChild(_menu_item[0]);
    }
    menu_new->addChild(_menu_item[1]);
    menu_new->addChild(_menu_item[2]);


    //////////////////////////////////////////////////////

    //set Developers title, Restore, Reset
    CCLabelTTF* developers_title = CCLabelTTF::create(_("settings_menu.developers.title"),
                                           ADLanguage::getFontName(),
                                           40);
    developers_title->setColor(GameInfo::COLOR_LIGHT_BLUE);
    ADMenuItem* developers = ADMenuItem::create(developers_title);
    CONNECT(developers->signalOnClick,
            this, &Settings::onDevelopersSelect);

    _menu_item.push_back(developers);

    /////////////////////////////////////////////////////

    CCLabelTTF* reset_title = CCLabelTTF::create(_("settings_menu.reset.title"),
                                           ADLanguage::getFontName(),
                                           40);
    reset_title->setColor(GameInfo::COLOR_LIGHT_BLUE);
    ADMenuItem* reset_progress = ADMenuItem::create(reset_title);
    CONNECT(reset_progress->signalOnClick,
            this, &Settings::onResetProgressSelect);

    _menu_item.push_back(reset_progress);

	ADMenuItem* restore = nullptr;
    //////////////////////////////////////////
	if (SavesManager::isPurchaseAllowed())
	{
		CCLabelTTF* restore_title = CCLabelTTF::create(_("settings_menu.restore.title"),
			ADLanguage::getFontName(),
			40);
		restore_title->setColor(GameInfo::COLOR_LIGHT_BLUE);
		restore = ADMenuItem::create(restore_title);
		CONNECT(restore->signalOnClick,
			this, &Settings::onRestorePurchasesSelect);
		_menu_item.push_back(restore);
	}
	else
	{
		_menu_item.push_back(nullptr);
	}


    menu->addChild(_menu_item[3]);
    menu->addChild(_menu_item[4]);
	if (SavesManager::isPurchaseAllowed())
	{
		menu->addChild(_menu_item[5]);
	}

    //_menu_item[3]->setPosition(ccp(0, -visibleSize.height/3 + origin.y ));
    menu->alignItemsVerticallyWithPadding(20/SCALE);
    menu_new->alignItemsHorizontallyWithPadding(70/SCALE);

    menu->setPosition(ccp(x_middle_of_sheet,
                          130/SCALE + ORIGIN.y));
    menu_new->setPosition(ccp(x_middle_of_sheet,
                              VISIBLE_SIZE.height/2 + 30/SCALE + ORIGIN.y));
	if (SavesManager::isPurchaseAllowed())
	{
		restore->setPositionY(restore->getPositionY() + 30 / SCALE);
	}

    this->addChild(menu);
    this->addChild(menu_new);

    _pop_up_manager.addMenuToAutoDisable(menu);
    _pop_up_manager.addMenuToAutoDisable(menu_new);

    for (unsigned int i=0; i<_menu_item.size(); ++i)
    {
        if(_menu_item[i])
        {
            _menu_item[i]->setOpacity(0);
            CCFadeTo* fade_in = CCFadeTo::create(0.3f, 255);
            _menu_item[i]->runAction(fade_in);
        }

    }
    return true;
}
bool
MCSkillLayer::init()
{
    if (MCBaseInfoLayer::init()) {
        CCSize winSize = CCDirectorGetWindowsSize();
        float contentScaleFactor = CC_CONTENT_SCALE_FACTOR();
        CCMenu *menu;
        CCLabelTTF *label;
        CCMenuItem *menuItem;
        float fontSize = 24.0f / contentScaleFactor;
        float offsetXLeft = 200 / contentScaleFactor;
        
        content_.push_back(JsonBox::Value("name"));
        
        content_.push_back(JsonBox::Value("releaseTime"));
        content_.push_back(JsonBox::Value("activeTime"));
        content_.push_back(JsonBox::Value("coldTime"));
        
        content_.push_back(JsonBox::Value("consume"));
        content_.push_back(JsonBox::Value("requiredProficiency"));
        
        content_.push_back(JsonBox::Value("revise"));
        content_.push_back(JsonBox::Value("count"));
        
        content_.push_back(JsonBox::Value("effect"));
        
        selectedSkill_ = NULL;
        
        /* 技能种类 */
        menu = CCMenu::create();
        
        label = CCLabelTTF::create("剑", "", fontSize);
        menuItem = CCMenuItemLabel::create(label,
                                           this,
                                           menu_selector(MCSkillLayer::selectSkillType));
        menuItem->setTag(MCSwordSkill);
        menu->addChild(menuItem);
        
        label = CCLabelTTF::create("锤", "", fontSize);
        menuItem = CCMenuItemLabel::create(label,
                                           this,
                                           menu_selector(MCSkillLayer::selectSkillType));
        menuItem->setTag(MCHammerSkill);
        menu->addChild(menuItem);
        
        label = CCLabelTTF::create("斧", "", fontSize);
        menuItem = CCMenuItemLabel::create(label,
                                           this,
                                           menu_selector(MCSkillLayer::selectSkillType));
        menuItem->setTag(MCAxeSkill);
        menu->addChild(menuItem);
        
        label = CCLabelTTF::create("枪", "", fontSize);
        menuItem = CCMenuItemLabel::create(label,
                                           this,
                                           menu_selector(MCSkillLayer::selectSkillType));
        menuItem->setTag(MCSpearSkill);
        menu->addChild(menuItem);
        
        label = CCLabelTTF::create("弓", "", fontSize);
        menuItem = CCMenuItemLabel::create(label,
                                           this,
                                           menu_selector(MCSkillLayer::selectSkillType));
        menuItem->setTag(MCBowSkill);
        menu->addChild(menuItem);
        
        menu->alignItemsVerticallyWithPadding(4);
        addChild(menu);
        
        menu->setAnchorPoint(ccp(0, 0.5));
        menu->setPosition(ccp(offsetXLeft, winSize.height / 2));
        
        /* 技能表格 */
        tableViewSize_ = CCSizeMake(180 / contentScaleFactor,
                                    320 / contentScaleFactor);
        tableView_ = CCTableView::create(this, tableViewSize_);
        addChild(tableView_);
        tableView_->setDirection(kCCScrollViewDirectionVertical);
        tableView_->setDelegate(this);
        tableView_->setVerticalFillOrder(kCCTableViewFillTopDown);
        
        tableView_->setAnchorPoint(ccp(0, 0.5));
        tableView_->setPosition(ccp(menu->getPositionX() + menuItem->getContentSize().width,
                                    (winSize.height - tableViewSize_.height) / 2));
        
        contentTableView_ = CCTableView::create(this, tableViewSize_);
        addChild(contentTableView_);
        contentTableView_->setDirection(kCCScrollViewDirectionVertical);
        contentTableView_->setDelegate(this);
        contentTableView_->setVerticalFillOrder(kCCTableViewFillTopDown);
        
        contentTableView_->setAnchorPoint(ccp(0, 0.5));
        contentTableView_->setPosition(ccp(tableView_->getPositionX() + tableViewSize_.width,
                                           (winSize.height - tableViewSize_.height) / 2));
        contentTableView_->setVisible(false);
        
        icon_ = CCSprite::create();
        addChild(icon_);
        icon_->setAnchorPoint(ccp(1, 1));
        icon_->setPosition(ccp(winSize.width - 64.0f / contentScaleFactor,
                               winSize.height - 64.0f / contentScaleFactor));
        
        proficiency_ = CCLabelTTF::create("熟练度", "", fontSize);
        addChild(proficiency_);
        
        proficiency_->setAnchorPoint(ccp(1, 0));
        proficiency_->setPosition(ccp(winSize.width - 64.0f / contentScaleFactor,
                                      64.0f / contentScaleFactor));
        proficiency_->setVisible(false);
        
        selectedCell_ = NULL;
        selectedSkill_ = NULL;
        
        return true;
    }
    
    return false;
}
Esempio n. 26
0
		// on "init" you need to initialize your instance
		bool MainMenu::init()
		{


			bool bRet = false;
			do 
			{
				//////////////////////////////////////////////////////////////////////////
				// super init first
				//////////////////////////////////////////////////////////////////////////

				if (! CCLayer::init())
				{
					break;
				}
				//////////////////////////////////////////////////////////////////////////
				// add your codes below...
				//////////////////////////////////////////////////////////////////////////

				// 1. add loading 
				CCSprite *pLoadSprite= CCSprite::create("loading.png");
				pLoadSprite->setAnchorPoint(CCPoint(0,0));
				this->addChild(pLoadSprite, 0, 1);

				// 2. add logo
				CCSprite* pLogo = CCSprite::create("logo.png");
				pLogo->setAnchorPoint(CCPoint(0,0));
				pLogo->setPosition(CCPoint(0, 320));
				this->addChild(pLogo, 10, 1);

				//menu.png




				// 3. Add menu items 
				// 3.1. NewGame button 
				// 
				CCSprite* pNewGameNormal = CCSprite::create("menu.png", CCRect(0, 0, 126, 33));
				CCSprite* pNewGameSelected = CCSprite::create("menu.png", CCRect(0, 33, 126, 33));
				CCSprite* pNewGameDisabled = CCSprite::create("menu.png", CCRect(0, 33 * 2, 126, 33));

				CCMenuItemSprite * pNewGameBtn = CCMenuItemSprite::create(
					pNewGameNormal,
					pNewGameSelected,
					pNewGameDisabled,
					this,
					menu_selector(MainMenu::onNewGame)
					);
				if(! pNewGameBtn)
					break;
				// 3.2. GameSetting button 
				// 
				CCSprite* pGameSettingsNormal = CCSprite::create("menu.png", CCRect(126, 0, 126, 33));
				CCSprite* pGameSettingsSelected = CCSprite::create("menu.png", CCRect(126, 33, 126, 33));
				CCSprite* pGameSettingsDisabled = CCSprite::create("menu.png", CCRect(126, 33 * 2, 126, 33));

				CCMenuItemSprite * pGameSettingsBtn = CCMenuItemSprite::create(
					pGameSettingsNormal,
					pGameSettingsSelected,
					pGameSettingsDisabled,
					this,
					menu_selector(MainMenu::onSettings)
					// 			[this](CCObject* pSender)
					// 		{
					// 			// "close" menu item clicked
					// 			//CCDirector::sharedDirector()->end();
					// 			this->flareEffect(); 
					// 		}

					);
				if(! pGameSettingsBtn)
					break;
				// 3.2. GameSetting button 
				// 
				CCSprite* pAboutNormal = CCSprite::create("menu.png", CCRect(252, 0, 126, 33));
				CCSprite* pAboutSelected = CCSprite::create("menu.png", CCRect(252, 33, 126, 33));
				CCSprite* pAboutDisabled = CCSprite::create("menu.png", CCRect(252, 33 * 2, 126, 33));

				CCMenuItemSprite * pAboutBtn = CCMenuItemSprite::create(
					pAboutNormal,
					pAboutSelected,
					pAboutDisabled,
					this,
					menu_selector(MainMenu::onAbout)
					);
				if(! pAboutBtn)
					break;
				this->_winSize = CCDirector::sharedDirector()->getWinSize();

				// 3.3. Main menu
				CCMenu* pMenu = CCMenu::create(pNewGameBtn, pGameSettingsBtn, pAboutBtn, NULL);
				pMenu->setPosition(CCPointZero);
				if(! pMenu)
					break;
				pMenu->alignItemsVerticallyWithPadding(10);
				this->addChild(pMenu, 1, 2);
				pMenu->setPosition(ccp(_winSize.width / 2, _winSize.height / 2));
				//this->schedule(update, 0.1);

				// 3.4
				CCTexture2D *tempShip = CCTextureCache::sharedTextureCache()->addImage("ship01.png");
				this->_ship	 = CCSprite::createWithTexture(tempShip, CCRect(0, 45, 60, 38));
				this->addChild(this->_ship, 0, 4);
				CCPoint pos = ccp(0.1 * _winSize.width, 0);
				this->_ship->setPosition(pos);
				this->_ship->runAction(CCMoveBy::create(2, CCPoint(0.5 * _winSize.width, pos.y + _winSize.height + 100)));

				CocosDenshion::SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.7f);
				CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic("Music\\mainMainMusic.mp3");
				this->scheduleUpdate();
				//// 1. Add a menu item with "X" image, which is clicked to quit the program.

				//// Create a "close" menu item with close icon, it's an auto release object.
				//CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
				//    "CloseNormal.png",
				//    "CloseSelected.png",
				//    this,
				//    menu_selector(HelloWorld::onAbout));
				//CC_BREAK_IF(! pCloseItem);

				//// Place the menu item bottom-right conner.
				//pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20));

				//// Create a menu with the "close" menu item, it's an auto release object.
				//CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
				//pMenu->setPosition(CCPointZero);
				//CC_BREAK_IF(! pMenu);

				//// Add the menu to HelloWorld layer as a child layer.
				//this->addChild(pMenu, 1);

				//// 2. Add a label shows "Hello World".

				//// Create a label and initialize with string "Hello World".
				//CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
				//CC_BREAK_IF(! pLabel);

				//// Get window size and place the label upper. 
				//CCSize size = CCDirector::sharedDirector()->getWinSize();
				//pLabel->setPosition(ccp(size.width / 2, size.height - 50));

				//// Add the label to HelloWorld layer as a child layer.
				//this->addChild(pLabel, 1);

				//// 3. Add add a splash screen, show the cocos2d splash image.
				//CCSprite* pSprite = CCSprite::create("HelloWorld.png");
				//CC_BREAK_IF(! pSprite);

				//// Place the sprite on the center of the screen
				//pSprite->setPosition(ccp(size.width/2, size.height/2));

				//// Add the sprite to HelloWorld layer as a child layer.
				//this->addChild(pSprite, 0);

				bRet = true;
			} while (0);

			return bRet;
		}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
	// Static reference
    mytry = this;

    // Init
    if ( !CCLayer::init() )
    {
        return false;
    }
    // Menu
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback) );
    pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );

    // Menu
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition( CCPointZero );
    this->addChild(pMenu, 1);

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    // Hello World
    InterfaceJNI::helloWorld();
#endif

    // Welcome
    CCLabelTTF* pLabel = CCLabelTTF::create("CCSocialNetwork", "Thonburi", 34);
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
    this->addChild(pLabel, 1);

    // Static Label Score
    CCLabelTTF* scLabel = CCLabelTTF::create("Your Score:", "Thonburi", 34);
    scLabel->setPosition( ccp(10 + scLabel->getContentSize().width/2, size.height - 20) );
    this->addChild(scLabel, 1);

    // Simulate var Score
    sLabel = CCLabelTTF::create("123", "Thonburi", 34);
    sLabel->setPosition( ccp(10 + scLabel->getContentSize().width/2, size.height - 60) );
    this->addChild(sLabel, 1);

    // Internet Label
	CCLabelTTF* internetLabel = CCLabelTTF::create("Internet Connection:", "Thonburi", 20);
	CCLabelTTF* internetValueLabel = CCLabelTTF::create("", "Thonburi", 20);
	internetLabel->setPosition( ccp(10 + internetLabel->getContentSize().width/2, size.height - 90) );
	internetValueLabel->setPosition( ccp(10 + internetValueLabel->getContentSize().width/2, size.height - 120) );
	this->addChild(internetLabel, 1);
	this->addChild(internetValueLabel, 1);

	// Check Internet
	CCLog("Go to check Internet connection...");
	bool internet = this->tryIsInternetConnection();
    if (internet)
    {
        internetValueLabel->setString("Connected YES");
    }
    else
    {
        internetValueLabel->setString("Connected NO");
    }
	CCLog("Internet connection value: %d", internet);


    mLabel = CCLabelTTF::create("", "Thonburi", 20);
    mLabel->setPosition(ccp(size.width/2, 20));
    this->addChild(mLabel);


    //Main Menu With Font
    CCLabelTTF *sendMailButtonLabel = CCLabelTTF::create("Send an email", "Thonburi", 24);
	CCMenuItemLabel *sendMailButton = CCMenuItemLabel::create(sendMailButtonLabel, this, menu_selector(HelloWorld::trySendAnEmail));

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    CCLabelTTF *sendMailButtonLabelInApp = CCLabelTTF::create("Send an email (in app mailer)", "Thonburi", 24);
	CCMenuItemLabel *sendMailButtonInApp = CCMenuItemLabel::create(sendMailButtonLabelInApp, this, menu_selector(HelloWorld::trySendAnEmailInApp));
#endif

    CCLabelTTF *sendTweetButtonLabel = CCLabelTTF::create("Send a tweet", "Thonburi", 24);
	CCMenuItemLabel *sendTweetButton = CCMenuItemLabel::create(sendTweetButtonLabel, this, menu_selector(HelloWorld::trySendATweet));

    CCLabelTTF *postOnFBButtonLabel = CCLabelTTF::create("Post on FB", "Thonburi", 24);
	CCMenuItemLabel *postOnFBButton = CCMenuItemLabel::create(postOnFBButtonLabel, this, menu_selector(HelloWorld::tryPostOnFB));

	CCMenu *mainMenu = CCMenu::create(sendMailButton,
                                      #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
                                      sendMailButtonInApp,
                                      #endif
                                      sendTweetButton, postOnFBButton, NULL);

	mainMenu->alignItemsVerticallyWithPadding(size.height * 0.06f);
	mainMenu->setPosition(ccp(size.width/2, size.height/2));

    this->addChild(mainMenu, 1);
    

    return true;
}
Esempio n. 28
0
bool SysMenu::init()
{
	bool ret = false;
	do
	{
		CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(s_texttureOpaquePack_plist);
		CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(s_textureTransparentPack_plist);

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

		//±³¾°
		CCSprite* loading = CCSprite::create(s_loading);
		loading->setAnchorPoint(ccp(0,0));
		this->addChild(loading);
		//LOGO 
		CCSprite* logo = CCSprite::create(s_logo);
		logo->setAnchorPoint(ccp(0,0));
		logo->setPosition(ccp(0,250));
		this->addChild(logo);

		CCSprite* newGameNormal			= CCSprite::create(s_menu,CCRectMake(0,0,126,33));
		CCSprite* newGameSelect			= CCSprite::create(s_menu,CCRectMake(0,33,126,33));
		CCSprite* newGameDisable		= CCSprite::create(s_menu,CCRectMake(0,33*2,126,33));
		
		CCSprite* gameSettingNormal		= CCSprite::create(s_menu,CCRectMake(126,0,126,33));
		CCSprite* gameSettingSelect		= CCSprite::create(s_menu,CCRectMake(126,33,126,33));
		CCSprite* gameSettingDisable	= CCSprite::create(s_menu,CCRectMake(126,33*2,126,33));

		CCSprite* aboutNormal			= CCSprite::create(s_menu,CCRectMake(126*2,0,126,33));
		CCSprite* aboutSelect			= CCSprite::create(s_menu,CCRectMake(126*2,33,126,33));
		CCSprite* aboutDisable			= CCSprite::create(s_menu,CCRectMake(126*2,33*2,126,33));

		CCMenuItemSprite* newGame = CCMenuItemSprite::create(newGameNormal,newGameSelect,newGameDisable,
			this,menu_selector(SysMenu::menuNewGameCallBack));
		CCMenuItemSprite* gameSetting = CCMenuItemSprite::create(gameSettingNormal,gameSettingSelect,gameSettingDisable,
			this,menu_selector(SysMenu::menuGameSettingCallBack));
		CCMenuItemSprite* about = CCMenuItemSprite::create(aboutNormal,aboutSelect,aboutDisable,
			this,menu_selector(SysMenu::menuAboutCallBack));


		CCMenu* menu = CCMenu::create(newGame,gameSetting,about,NULL);
		menu->alignItemsVerticallyWithPadding(10);
		this->addChild(menu,1,2);
		menu->setPosition(size.width/2,size.height/2-80);

		this->schedule(schedule_selector(SysMenu::update),0.1f);

		this->ship = CCSprite::createWithSpriteFrameName("ship01.png");
		this->addChild(ship,0,4);

		CCPoint p = ccp(CCRANDOM_0_1()*size.width,0);

		ship->setPosition(p);
		ship->runAction(CCMoveBy::create(2,ccp(CCRANDOM_0_1()*size.width,p.y+size.height+100)));

		CocosDenshion::SimpleAudioEngine::sharedEngine()->setEffectsVolume(0.7f);
		CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic(s_mainMainMusic,true);

		this->setKeypadEnabled(true);

		ret = true;

	}while (0);

	return ret;
}
Loading::Loading()
{
    glClearColor(0.0f/255.0f, 0.0f/255.0f, 0.0f/255.0f, 1.0f);
    setTouchEnabled( true );

    float scale = ScreenHelper::getTextureScale();
    float scaleX = ScreenHelper::getTextureScaleX();
    float scaleY = ScreenHelper::getTextureScaleY();
    
    CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Buttons.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Buttons.plist");
    
    CCTextureCache::sharedTextureCache()->addPVRImage("ctm_Icons.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ctm_Icons.plist");
    
    CCTextureCache::sharedTextureCache()->addPVRImage("LoadingScreen.pvr.ccz");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("LoadingScreen.plist");
    
    CCPoint scalePoint;
    scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
    scalePoint.y += -5*scale;
    CCSprite *sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_Screen_ver2.png");
    sprite->setScale(scale);
    sprite->setPosition(scalePoint);
    addChild(sprite);
    
    
    sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_ProgressScroll_Graphic.png");
    sprite->setScaleX(scaleX);
    sprite->setScaleY(scaleY*1.2f);
    sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_LEFT,-140.0f,-50.0f));
    loadingBar = sprite;
    addChild(sprite,2);
    
    
    sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_TopPanel.png");
    sprite->setScaleX(scaleX);
    sprite->setScaleY(scaleY);
    sprite->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,0.0f,-55.0f));
    addChild(sprite,2);
    
    sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_TopOverlay.png");
    sprite->setScaleX(scaleX);
    sprite->setScaleY(scaleY);
    sprite->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER));
    addChild(sprite,2);
    
    sprite = CCSprite::createWithSpriteFrameName("BackgroundPlate.png");
    sprite->setScale(scale);
    scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
    scalePoint.x += -135.0f*scale;
    scalePoint.y += -97.0f*scale;
    sprite->setPosition(scalePoint);
    addChild(sprite,2);
    
    sprite = CCSprite::createWithSpriteFrameName("BronzeText.png");
    sprite->setScale(scale);
    scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
    scalePoint.x += -135.0f*scale;
    scalePoint.y += -97.0f*scale;
    sprite->setPosition(scalePoint);
    addChild(sprite,2);
    
    CCLabelTTF *label = CCLabelTTF::create(LevelSelect::getLevelName(), "impact.ttf", 42*scale);
    addChild(label, 2);
    label->setColor(ccc3(0,0,0));
    label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,2.0f,-44.0f));
    
    label = CCLabelTTF::create(LevelSelect::getLevelName(), "impact.ttf", 42*scale);
    addChild(label, 2);
    label->setColor(ccc3(237,188,0));
    label->setPosition(ScreenHelper::getAnchorPointPlusOffset(ScreenHelper::ANCHOR_TOP_CENTER,0.0f,-42.0f));
    
    int currentLevel = LevelSelect::getCurrentLevel();
    if(currentLevel >= BONUS_LEVELSTART)
        g_isTrickLevel = true;
    else
        g_isTrickLevel = false;
    
    
    int medalLevel = SaveLoad::m_SaveData.medalLockLevel;
    int showMedal = 0;
    if(medalLevel==0)
    {
        if(SaveLoad::m_SaveData.levelflags[currentLevel] & SaveLoad::ONE_COCONUT)
            showMedal = 1;
    }
    if(medalLevel==1)
    {
        if(SaveLoad::m_SaveData.levelflags[currentLevel] & SaveLoad::TWO_COCONUT)
            showMedal = 2;
    }
    if(medalLevel==2)
    {
        if(SaveLoad::m_SaveData.levelflags[currentLevel] & SaveLoad::THREE_COCONUT)
            showMedal = 3;
    }
    
    if(!showMedal)
    {
        CCSize dimensions;
        dimensions.width = 100*scale;
        dimensions.height  = 25*scale;
        label = CCLabelTTF::create("Time:", "impact.ttf", 21*scale,dimensions,kCCTextAlignmentLeft);
        addChild(label, 2);
        label->setColor(ccc3(237,188,0));

        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += (-240.0f+90.0f)*scale;
        scalePoint.y += 50.0f*scale;
        label->setPosition(scalePoint);
        
        char tempLabelStr[32];
        sprintf(tempLabelStr,"%.2f",LevelSelect::getLevelGoals()->time);
        label = CCLabelTTF::create(tempLabelStr, "impact.ttf", 21*scale,dimensions,kCCTextAlignmentLeft);
        addChild(label, 2);
        label->setColor(ccc3(255,255,255));
        
        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += (-240.0f+150.0f)*scale;
        scalePoint.y += 50.0f*scale;
        label->setPosition(scalePoint);
                
        label = CCLabelTTF::create("Peanuts:", "impact.ttf", 21*scale,dimensions,kCCTextAlignmentLeft);
        addChild(label, 2);
        label->setColor(ccc3(237,188,0));
        
        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += (-240.0f+90.0f)*scale;
        scalePoint.y += 20.0f*scale;
        label->setPosition(scalePoint);
        
        sprintf(tempLabelStr,"%d",LevelSelect::getLevelGoals()->peanuts);
        label = CCLabelTTF::create(tempLabelStr, "impact.ttf", 21*scale,dimensions,kCCTextAlignmentLeft);
        addChild(label, 2);
        label->setColor(ccc3(255,255,255));
        
        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += (-240.0f+170.0f)*scale;
        scalePoint.y += 20.0f*scale;
        label->setPosition(scalePoint);
        
        label = CCLabelTTF::create("Points:", "impact.ttf", 21*scale,dimensions,kCCTextAlignmentLeft);
        addChild(label, 2);
        label->setColor(ccc3(237,188,0));
        
        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += (-240.0f+90.0f)*scale;
        scalePoint.y += -10.0f*scale;
        label->setPosition(scalePoint);
        
        sprintf(tempLabelStr,"%d",LevelSelect::getLevelGoals()->points);
        label = CCLabelTTF::create(tempLabelStr, "impact.ttf", 21*scale,dimensions,kCCTextAlignmentLeft);
        addChild(label, 2);
        label->setColor(ccc3(255,255,255));

        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += (-240.0f+160.0f)*scale;
        scalePoint.y += -10.0f*scale;
        label->setPosition(scalePoint);        
    }
    else
    {
        CCTextureCache::sharedTextureCache()->addPVRImage("LoadingScreen2.pvr.ccz");
        CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("LoadingScreen2.plist");

        if(showMedal == 1)
            sprite = CCSprite::createWithSpriteFrameName("ctm_BronzeMedalBig.png");
        if(showMedal == 2)
            sprite = CCSprite::createWithSpriteFrameName("ctm_SilverMedalBig.png");
        if(showMedal == 3)
            sprite = CCSprite::createWithSpriteFrameName("ctm_Loading_LargeGold.png");
        
        sprite->setScale(scale);
        scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
        scalePoint.x += -135.0f*scale;
        scalePoint.y += 5.0f*scale;
        sprite->setPosition(scalePoint);
        addChild(sprite,2);
    }
    
    CCMenuItem *StoreButton = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("ctm_Button_17.png"), CCSprite::createWithSpriteFrameName("ctm_Button_17_Down.png"), this, menu_selector(Loading::storeButtonTapped));
    StoreButton->setScale(scale);
    scalePoint = ccp(0,0);
    scalePoint.x += 85.0f*scale;
    scalePoint.y += -100.0f*scale;
    StoreButton->setPosition(scalePoint);
    
    CCMenu* menu = CCMenu::create(StoreButton, NULL);
    menu->setPosition(ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER));
    addChild(menu,4);
    
    
    
    CCMenuItemSprite *items[3];
    //if(SaveLoad::m_SaveData.numDoubleNuts)
    {
        CCSize dim;
        dim.width = 200.0f;
        dim.height = 35.0f;
        CCSprite *barImage = CCSprite::create("ctm_UI_smallGreyStrip_ver1.png");
        CCSprite *barImageSel = CCSprite::create("ctm_UI_smallGreyStrip_ver1.png");
        barImage->setOpacity(0);
        barImageSel->setOpacity(0);
        CCMenuItemSprite *menuImage = CCMenuItemSprite::create(barImage,barImageSel,this,menu_selector(Loading::nutsButtonTapped));
        CCLabelTTF *blabel = CCLabelTTF::create(" Use 2X Peanuts","Jacoby ICG Black.ttf",18,dim,kCCTextAlignmentLeft);
        blabel->setColor(ccc3(237,188,0));
        blabel->setPosition(ccp(157.0f,18.0f));
        menuImage->addChild(blabel,0,1234);
        items[1] = menuImage;
        CCSprite *sprite = CCSprite::createWithSpriteFrameName("ctm_icon_Store_17_2X-peanuts.png");
        sprite->setPosition(ccp(30,23));
        sprite->setScale(0.925f);
        menuImage->addChild(sprite,0,4321);
        menuImage->setScale(scale);
        
        if(!SaveLoad::m_SaveData.numDoubleNuts)
        {
            //[menuImage setIsEnabled:NO];
            blabel->setColor(ccc3(237/2,188/2,0));
            sprite->setColor(ccc3(128,128,128));
        }
        
    }
    //if(SaveLoad::m_SaveData.numLevelFire)
    {
        CCSize dim;
        dim.width = 200.0f;
        dim.height = 35.0f;
        CCSprite *barImage = CCSprite::create("ctm_UI_smallGreyStrip_ver1.png");
        CCSprite *barImageSel = CCSprite::create("ctm_UI_smallGreyStrip_ver1.png");
        barImage->setOpacity(0);
        barImageSel->setOpacity(0);
        CCMenuItemSprite *menuImage = CCMenuItemSprite::create(barImage,barImageSel,this,menu_selector(Loading::fireButtonTapped));
        CCLabelTTF *blabel = CCLabelTTF::create(" Use Permanent Fire","Jacoby ICG Black.ttf",18,dim,kCCTextAlignmentLeft);
        blabel->setColor(ccc3(237,188,0));
        blabel->setPosition(ccp(157.0f,18.0f));
        menuImage->addChild(blabel,0,1234);
        items[2] = menuImage;
        CCSprite *sprite = CCSprite::createWithSpriteFrameName("ctm_icon_Store_18_Fire.png");
        sprite->setPosition(ccp(30,23));
        sprite->setScale(0.925f);
        menuImage->addChild(sprite,0,4321);
        menuImage->setScale(scale);
        
        if(!SaveLoad::m_SaveData.numLevelFire)
        {
            //[menuImage setIsEnabled:NO];
            blabel->setColor(ccc3(237/2,188/2,0));
            sprite->setColor(ccc3(128,128,128));
        }
    }
    //if(SaveLoad::m_SaveData.numTimeSlow)
    {
        
        CCSize dim;
        dim.width = 200.0f;
        dim.height = 35.0f;
        CCSprite *barImage = CCSprite::create("ctm_UI_smallGreyStrip_ver1.png");
        CCSprite *barImageSel = CCSprite::create("ctm_UI_smallGreyStrip_ver1.png");
        barImage->setOpacity(0);
        barImageSel->setOpacity(0);
        CCMenuItemSprite *menuImage = CCMenuItemSprite::create(barImage,barImageSel,this,menu_selector(Loading::timeButtonTapped));
        CCLabelTTF *blabel = CCLabelTTF::create(" Use Slow Clock","Jacoby ICG Black.ttf",18,dim,kCCTextAlignmentLeft);
        blabel->setColor(ccc3(237,188,0));
        blabel->setPosition(ccp(157.0f,18.0f));
        menuImage->addChild(blabel,0,1234);
        items[0] = menuImage;
        CCSprite *sprite = CCSprite::createWithSpriteFrameName("ctm_icon_Store_16_Slow-Clock.png");
        sprite->setPosition(ccp(30,23));
        sprite->setScale(0.925f);
        menuImage->addChild(sprite,0,4321);
        menuImage->setScale(scale);
        
        if(!SaveLoad::m_SaveData.numTimeSlow)
        {
            //[menuImage setIsEnabled:NO];
            blabel->setColor(ccc3(237/2,188/2,0));
            sprite->setColor(ccc3(128,128,128));
        }

        
    }
    CCMenu *powerUpMenu = CCMenu::create(items[0], items[1], items[2], NULL);
    
    powerUpMenu->alignItemsVerticallyWithPadding(-10.0);
    scalePoint = ScreenHelper::getAnchorPoint(ScreenHelper::ANCHOR_CENTER);
    scalePoint.x += 100.0f*scale;
    scalePoint.y += 10.0f*scale;
    powerUpMenu->setPosition(scalePoint);
    addChild(powerUpMenu);
    
    
    m_TimeOut = 3.0f;
    scheduleUpdate();
}
Esempio n. 30
0
// Initialize the menu items, background, and overall setup of the music selection menu
//
// return - false if there was an error in initializing, true otherwise
bool MusicSelect::init()
{
    CCLabelTTF*      labelFirstSong;    // the text for the first song menu item
    CCLabelTTF*      labelSecondSong;   // the text for the second song menu item
    CCLabelTTF*      labelThirdSong;    // the text for the third song menu item
    CCLabelTTF*      labelYourMusic;    // the text for your music menu item
    CCLabelTTF*      labelPlay;         // the text for play menu item
    CCLabelTTF*      labelBack;         // the text for back menu item
    CCMenuItemLabel* itemFirstSong;     // menu item for choosing the first song
    CCMenuItemLabel* itemSecondSong;    // menu item for choosing the second song
    CCMenuItemLabel* itemThirdSong;     // menu item for choosing the third song
    CCMenuItemLabel* itemYourMusic;     // menu item for opening your music selection
    CCMenuItemLabel* itemBack;          // menu item for going back to character select
    CCMenu*          menu;              // menu to contain the menu items
    CCSize           size;              // the size of the window

    if(!CCLayer::init())
    {
        return false;
    }

    // get the window size from the director
    size = CCDirector::sharedDirector()->getWinSize();

    // create the header for the scene
    m_header = CCLabelTTF::create("Choose a song", FONT_STYLE, Font_Size_Small);
    m_header->setPosition( ccp(size.width * POS_HALF_SCREEN, size.height * POS_HEADER_HEIGHT) );
    m_header->setColor(MENU_COLOR);
    this->addChild(m_header, 1);

    // create the text for the menu items
    labelFirstSong  = CCLabelTTF::create("Letting Go - UltraMax", FONT_STYLE, Font_Size_Default);
    labelSecondSong = CCLabelTTF::create("The Call of Stars - UltraMax", FONT_STYLE, Font_Size_Default);
    labelThirdSong  = CCLabelTTF::create("Waiting - UltraMax", FONT_STYLE, Font_Size_Default);
    labelYourMusic  = CCLabelTTF::create("Select from SD card", FONT_STYLE, Font_Size_Default);
    labelBack       = CCLabelTTF::create("Back", FONT_STYLE, Font_Size_Default);
    labelPlay       = CCLabelTTF::create("Play", FONT_STYLE, Font_Size_Default);

    // create the items for the menu
    itemFirstSong  = CCMenuItemLabel::create(labelFirstSong, this, menu_selector(MusicSelect::HandleFirstSongPressed));
    itemSecondSong = CCMenuItemLabel::create(labelSecondSong, this, menu_selector(MusicSelect::HandleSecondSongPressed));
    itemThirdSong  = CCMenuItemLabel::create(labelThirdSong, this, menu_selector(MusicSelect::HandleThirdSongPressed));
    itemYourMusic  = CCMenuItemLabel::create(labelYourMusic, this, menu_selector(MusicSelect::HandleYourMusicPressed));
    itemBack       = CCMenuItemLabel::create(labelBack, this, menu_selector(MusicSelect::HandleBackPressed));
    m_itemPlay     = CCMenuItemLabel::create(labelPlay, this, menu_selector(MusicSelect::HandlePlayPressed));

    // set the color of the menu items
    itemFirstSong->setColor(FONT_COLOR);
    itemSecondSong->setColor(FONT_COLOR);
    itemThirdSong->setColor(FONT_COLOR);
    itemYourMusic->setColor(FONT_COLOR);
    itemBack->setColor(FONT_COLOR);
    m_itemPlay->setColor(FONT_COLOR);

    // disable the play menu item, because user needs to pick a song first
    m_itemPlay->setVisible(false);
    m_itemPlay->setEnabled(false);

    // create menu to contain the menu items
    menu = CCMenu::create(itemFirstSong, itemSecondSong, itemThirdSong, itemYourMusic, m_itemPlay, itemBack, NULL);
    menu->alignItemsVerticallyWithPadding(MENU_PADDING);
    menu->setPosition(size.width * POS_HALF_SCREEN, size.height * MENU_POS_HEIGHT);
    this->addChild(menu, 1);

    // initialize the booleans
    m_choseUserMusic = false;
    m_haveJniData    = false;
    m_songSelected   = false;

    return true;
}