예제 #1
0
void MenuLayer2::menuCallbackOpacity(NSObject* sender)
{
	CCMenu* menu = (CCMenu*)(((CCNode*)(sender))->getParent());
	GLubyte opacity = menu->getOpacity();
	if( opacity == 128 )
		menu->setOpacity(255);
	else
		menu->setOpacity(128);	 
}
예제 #2
0
void ConfigMenu::makeMenu(){
	CCMenuItemFont::setFontSize(50);
	CCMenuItemFont::setFontName("Arial");


	//CCMenuItemToggle* music = CCMenuItemToggle::createWithTarget(this, menu_selector(ConfigMenu::musicMenuCallback), 
		//CCMenuItemFont::create("Music OFF"),
		//CCMenuItemFont::create("Music ON"), NULL);
	CCMenuItemToggle* music = CCMenuItemToggle::createWithTarget(this, menu_selector(ConfigMenu::musicMenuCallback),
		CCMenuItemLabel::create(CCLabelBMFont::create("Music OFF", "arial-unicode-26.fnt", 300)), 
		CCMenuItemLabel::create(CCLabelBMFont::create("Music ON", "arial-unicode-26.fnt", 300)), NULL);
	
	CCLabelBMFont* txtShare = CCLabelBMFont::create("Share", "arial-unicode-26.fnt", 300);
	//CCMenuItemFont* share = CCMenuItemFont::create("Share", this, menu_selector(ConfigMenu::shareMenuCallback));
	//CCLabelTTF* d = CCLabelTTF::create("Share", "Arial", 30);
	CCMenuItemLabel* share = CCMenuItemLabel::create(txtShare, this, menu_selector(ConfigMenu::shareMenuCallback));
	music->setPosition(ccp(0,-60));
	share->setPosition(ccp(0, music->getContentSize().height+music->getPositionY()+20));
	share->setScale(2);
	music->setScale(2);
	CCMenu *menu = CCMenu::create(music, share, NULL);
	//menu->setPosition(ccp(400,0));
	menu->setOpacity(kCCMenuHandlerPriority);
	this->addChild(menu);
	if(!CCUserDefault::sharedUserDefault()->getBoolForKey(CONFIG_KEY_HAS_MUSIC)){
		music->setSelectedIndex(1);
	}else{
		music->setSelectedIndex(0);
	}

}
예제 #3
0
void GameScene::showRetryButtons()
{
	CCMenuItemImage* retryButton = CCMenuItemImage::create(
			"ButtonRetry.png","ButtonRetry.png", this, menu_selector(GameScene::tapRetryButton));

	CCMenuItemImage* wallButton = CCMenuItemImage::create(
			"ButtonWall.png", "ButtonWall.png" , this, menu_selector(GameScene::tapWallButton));

	CCMenuItemImage* titleButton = CCMenuItemImage::create(
			"ButtonTitle.png","ButtonTitle.png", this, menu_selector(GameScene::tapTitleButton));

	CCMenu* menu = CCMenu::create(retryButton, wallButton, titleButton, NULL);
	menu->alignItemsHorizontallyWithPadding( 30.0f);
	menu->setOpacity(0);
	//menu->setPosition(ccp(m_winSize.width / 2,m_winSize.height * 1.2));
	//menu->setPosition(ccp(m_winSize.width / 2,m_winSize.height/ 4 - 10));
	this->addChild(menu,kZOrderScore,kTagMenu);

	CCFiniteTimeAction* initFade = CCFadeTo::create(0.0f,0);
	CCFiniteTimeAction* initMove = CCMoveTo::create(0.0f,ccp(m_winSize.width / 2,50.0f - 10.0f));
	CCSequence* initMix = CCSequence::createWithTwoActions(initFade,initMove);

	CCFiniteTimeAction* fade = CCFadeIn::create(1.5f);
	CCFiniteTimeAction* move = CCMoveBy::create(1.5f,ccp(0,10.0f));
	CCSpawn* mix = CCSpawn::createWithTwoActions(fade,move);
	CCActionInterval* easeMix = CCEaseIn::create( CCSequence::createWithTwoActions(initMix,mix), 2.0f);

	menu->runAction(easeMix);
}
예제 #4
0
void MainGameScene::returnMainGame()
{
    setTouchEnabled(true);
    CCMenu* resumeDialog = (CCMenu*)this->getChildByTag(tagResumeDialog);
    if(resumeDialog){
        resumeDialog->setOpacity(0);
        resumeDialog->setEnabled(false);
    }
}
예제 #5
0
void LevelSelectScene::hiddenStartMenu()
{
    CCMenu* startMenu = (CCMenu*)this->getChildByTag(tagStartMenuDialog);
    if(startMenu){
        this->removeChild(startMenu);
    }
    
    CCMenu* levelSelectMenu = (CCMenu*)this->getChildByTag(tagLevelSelectMenuDialog);
    if(levelSelectMenu){
        levelSelectMenu->setOpacity(255);
        levelSelectMenu->setEnabled(true);
    }
    
}
예제 #6
0
void MainGameScene::makeClearDaialog()
{
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    CCMenuItemImage* titleItem = CCMenuItemImage::create("logo_menu.png","logo_menu.png" ,this, menu_selector(MainGameScene::tapTitleButton));
    titleItem->setPosition(ccp(winSize.width * 0.3, winSize.height * 0.3));
    
    CCMenuItemImage* retryItem = CCMenuItemImage::create("logo_restart.png","logo_restart.png" ,this, menu_selector(MainGameScene::tapRetryButton));
    retryItem->setPosition(ccp(winSize.width * 0.8, winSize.height * 0.3));
    
    CCMenu* clearDialog = CCMenu::create(titleItem,retryItem,NULL);
    clearDialog->setPosition(CCPointZero);
    clearDialog->setTag(tagClearDialog);
    clearDialog->setOpacity(0);
    clearDialog->setEnabled(false);
    this->addChild(clearDialog);
}
예제 #7
0
void HelloWorld::endGame()
{

	gameend = true;

	setTouchEnabled(false);

	if(this->bird->getPosition().y>320){
		CCLog("%f",this->bird->getPosition().y);
		this->bird->dead();
	}

	unscheduleUpdate();
	unschedule(schedule_selector(HelloWorld::addBar));

	//this->removeChild(this->bird);

	CCSprite *gameover = CCSprite::createWithSpriteFrameName("gameover.png");
	gameover->setPosition(ccp(this->screenSize.width/2,this->screenSize.height/2));
	gameover->runAction(CCMoveTo::create(0.5f,ccp(this->screenSize.width/2,this->screenSize.height/2+240)));
	addChild(gameover,1,1);

	//CCMenuItemImage *gameoverMenuItem = CCMenuItemImage::create("start.png","start.png",this,menu_selector(HelloWorld::gameEndCallback));
	CCMenuItemSprite  *gameoverMenuItem = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("start.png"),
		CCSprite::createWithSpriteFrameName("start.png"),this,menu_selector(HelloWorld::gameEndCallback));
	CCMenu *menu = CCMenu::create(gameoverMenuItem, NULL);
	//b2BodyDef gameoverMenuItemDef;
	//gameoverMenuItemDef.type = b2_staticBody;
	///gameoverMenuItemDef.position = b2Vec2(this->screenSize.width/2/RATIO,this->screenSize.height/2/RATIO);
	//b2Body *gameoverBody = this->world->CreateBody(&gameoverMenuItemDef);
	//menu->setPosition( CCPointZero );
	menu->setPosition(ccp(this->screenSize.width/2,this->screenSize.height/2-100));
	menu->setOpacity(0);

	CCActionInterval*  move = CCMoveBy::create(0.5, ccp(0,100));
	CCActionInterval*  show = CCFadeIn::create(0.5);
	CCAction*  action = CCSpawn::create( show, move, NULL);
	CCFiniteTimeAction* taction = CCSequence::create(CCDelayTime::create(0.3),action,NULL);

	menu->runAction(taction);
	

	addChild(menu,1,2);
}
예제 #8
0
void MainGameScene::makeResumeDaialog()
{
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    
    //CCSpriteで作ると、タッチ判定無効とかめんどくさいからBGもMenuItemで作る
    CCMenuItemImage* resumeBG = CCMenuItemImage::create("logo_Info2.png","logo_Info2.png");
    resumeBG->setScale(0.7);
    resumeBG->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
    resumeBG->setEnabled(false);
    
    CCSize pResumeBGSize = resumeBG->getContentSize();
    CCLabelTTF* resumeLabel;
    
    resumeLabel = CCLabelTTF::create(NKLocalizedString::LocalizedString("resume", "RESUME"), "Copperplate", 60.0);
    resumeLabel->setColor(ccc3(0, 0, 0));
    resumeLabel->setPosition(ccp(pResumeBGSize.width * 0.5 ,pResumeBGSize.height * 0.7));
    resumeBG->addChild(resumeLabel);
   
    
    CCMenuItemImage* titleItem = CCMenuItemImage::create("button1.png","button1.png" ,this, menu_selector(MainGameScene::tapTitleButton));
    titleItem->setPosition(ccp(winSize.width * 0.3, winSize.height * 0.47));
    
    
    CCLabelTTF* titleLabel;
    titleLabel = CCLabelTTF::create("TITLE", "Arial", 30.0);
    
    CCSize pTitleItemSize = titleItem->getContentSize();
    titleLabel->setPosition(ccp(pTitleItemSize.width / 2 ,pTitleItemSize.height / 2));
    titleItem->addChild(titleLabel);
    titleItem->setScale(0.8);

    
    
    CCMenuItemImage* returnGameItem = CCMenuItemImage::create("button2.png","button2.png" ,this, menu_selector(MainGameScene::returnMainGame));
    returnGameItem->setPosition(ccp(winSize.width * 0.7, winSize.height * 0.47));
    
    CCLabelTTF* returnGameLabel;
    returnGameLabel = CCLabelTTF::create("CANCEL", "Arial", 30.0);
    
    CCSize pReturnGameSize = returnGameItem->getContentSize();
    returnGameLabel->setPosition(ccp(pReturnGameSize.width / 2 ,pReturnGameSize.height / 2));
    returnGameItem->addChild(returnGameLabel);
    returnGameItem->setScale(0.8);
    
    CCMenuItemImage* retryGameItem = CCMenuItemImage::create("button3.png","button3.png" ,this, menu_selector(MainGameScene::doRetry));
    retryGameItem->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.39));
    
    CCLabelTTF* retryGameLabel;
    retryGameLabel = CCLabelTTF::create("RETRY", "Arial", 30.0);
    
    CCSize pRetryGameSize = retryGameItem->getContentSize();
    retryGameLabel->setPosition(ccp(pRetryGameSize.width / 2 ,pRetryGameSize.height / 2));
    retryGameItem->addChild(retryGameLabel);
    retryGameItem->setScale(0.8);

    
    
    CCMenu* resumeDialog = CCMenu::create(resumeBG, titleItem, returnGameItem,retryGameItem,NULL);
    resumeDialog->setPosition(CCPointZero);
    resumeDialog->setTag(tagResumeDialog);
    resumeDialog->setOpacity(0);
    resumeDialog->setZOrder(Z_ORDER_RESUME_DIALOG);
    resumeDialog->setEnabled(false);
    this->addChild(resumeDialog);
}
예제 #9
0
void LevelSelectScene::menuStartCallback(CCObject *pSender)
{
    
    CCMenu* levelSelectMenu = (CCMenu*)this->getChildByTag(tagLevelSelectMenuDialog);
    if(levelSelectMenu){
        levelSelectMenu->setOpacity(128);
        levelSelectMenu->setEnabled(false);
    }
    
    CCMenuItemImage* targetLevelImage = (CCMenuItemImage*)pSender;
    m_level = targetLevelImage->getTag();
    
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    CCMenuItemImage* startMenuBG = CCMenuItemImage::create("logo_Info2.png","logo_Info2.png");
    startMenuBG->setScale(0.7);
    startMenuBG->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
    startMenuBG->setEnabled(false);
    
    
    CCString* levelStr = CCString::createWithFormat("Lv:%d",m_level);
    CCSize pStartBGSize = startMenuBG->getContentSize();
    CCLabelTTF* levelLabel;
    levelLabel = CCLabelTTF::create(levelStr->getCString(), "Copperplate", 60.0);
    levelLabel->setColor(ccc3(0, 0, 0));
    levelLabel->setPosition(ccp(pStartBGSize.width * 0.5 ,pStartBGSize.height * 0.75));
    startMenuBG->addChild(levelLabel);

    //ハイスコアを表示
    CCString* bestStr = CCString::createWithFormat("MIN:%d  BEST:%d",min_score[m_level-1],best_score[m_level-1]);
    CCLabelTTF* bestLabel;
    bestLabel = CCLabelTTF::create(bestStr->getCString(), "Copperplate", 60.0);
    bestLabel->setColor(ccc3(0, 0, 0));
    bestLabel->setPosition(ccp(pStartBGSize.width * 0.5 ,pStartBGSize.height * 0.5));
    startMenuBG->addChild(bestLabel);
    
    
    CCMenuItemImage* titleItem = CCMenuItemImage::create("button1.png","button1.png" ,this, menu_selector(LevelSelectScene::startGame));
    titleItem->setPosition(ccp(winSize.width * 0.3, winSize.height * 0.42));
    
    
    CCLabelTTF* titleLabel;
    titleLabel = CCLabelTTF::create("START", "Arial", 30.0);
    
    CCSize pTitleItemSize = titleItem->getContentSize();
    titleLabel->setPosition(ccp(pTitleItemSize.width / 2 ,pTitleItemSize.height / 2));
    titleItem->addChild(titleLabel);
    titleItem->setScale(0.8);
    
    
    
    CCMenuItemImage* returnGameItem = CCMenuItemImage::create("button2.png","button2.png" ,this, menu_selector(LevelSelectScene::hiddenStartMenu));
    returnGameItem->setPosition(ccp(winSize.width * 0.7, winSize.height * 0.42));
    
    CCLabelTTF* returnGameLabel;
    returnGameLabel = CCLabelTTF::create("CANCEL", "Arial", 30.0);
    
    CCSize pReturnGameSize = returnGameItem->getContentSize();
    returnGameLabel->setPosition(ccp(pReturnGameSize.width / 2 ,pReturnGameSize.height / 2));
    returnGameItem->addChild(returnGameLabel);
    returnGameItem->setScale(0.8);
    
    
    
    CCMenu* resumeDialog = CCMenu::create(startMenuBG, titleItem, returnGameItem, NULL);
    resumeDialog->setPosition(CCPointZero);
    resumeDialog->setTag(tagStartMenuDialog);
    resumeDialog->setScale(winSize.width/640);
    this->addChild(resumeDialog);
    
   }