void PauseLayer::createLabel(const char *labelName, const char *labelNameValue, CCPoint position, CCSprite *objective) {
    float scale = Utility::isIPad() ? 1 : 0.5;
    CCLabelBMFont *label = CCLabelBMFont::create(labelName, kFontChubby,  0, kCCTextAlignmentLeft);
    label->setPosition(position);
    label->setScale(scale);
    label->setAnchorPoint(ccp(0, 1));
    objective-> addChild(label, 10);
    CCLabelBMFont *labelText = CCLabelBMFont::create(labelNameValue, kFontChubby, winSize.width * 0.4);
    //    labelText->
    labelText->setPosition(ccp(label->getPositionX(), label->getPositionY() - winSize.height * 0.078 ));
    labelText->setScale(scale * 0.65);
    labelText->setAnchorPoint(ccp(0, 1));
    objective->addChild(labelText, 10);
}
示例#2
0
CCNode* KCardActor::ShowHit(const char* slot,K3DActionParam* param,float scale,bool bGood)
{
	int val = param->GetVal(m_card->GetRealId());

	UIWidget* widget = GetWidget(slot);
	char msg[64];
	if(val >0){
		sprintf(msg,"+%d",val);
	}else{
		if(bGood){
			sprintf(msg,"+%d",val);
		}else{
			if(val==0)
				sprintf(msg,"-%d",val);
			else
				sprintf(msg,"%d",val);
		}
	}
	CCLabelBMFont* bmFont = CCLabelBMFont::create(msg,"GUI/num_1.fnt");
	bmFont->setAnchorPoint(ccp(0.50f,0.50f));
	bmFont->setPosition(widget->getWorldPosition());
	KUIAssist::_activeSceneLayer()->addChild(bmFont,100);

	bmFont->setScale(scale);
	m_objectDict.setObject(bmFont, "hit_text");
	return bmFont;
}
KDbool Ch3_SavingSimpleData::init ( KDvoid )
{	
	if ( !Recipe::init ( ) )
	{
		return KD_FALSE;
	}

	// Set font size
	CCMenuItemFont::setFontSize ( 30 );

	// Add main label
	CCLabelBMFont*	pChooseDifficultyLabel = CCLabelBMFont::create ( "CHOOSE DIFFICULTY:", "eurostile_30.fnt" );
	pChooseDifficultyLabel->setPosition ( ccp ( 240, 250 ) );
	pChooseDifficultyLabel->setScale ( 0.5f );
	this->addChild ( pChooseDifficultyLabel, 1 );
	
	// Add difficulty choices
	m_pEasyMIF	 = CCMenuItemFont::create ( "Easy"  , this, menu_selector ( Ch3_SavingSimpleData::chooseEasy ) );
	m_pMediumMIF = CCMenuItemFont::create ( "Medium", this, menu_selector ( Ch3_SavingSimpleData::chooseMedium ) );
	m_pHardMIF	 = CCMenuItemFont::create ( "Hard"  , this, menu_selector ( Ch3_SavingSimpleData::chooseHard ) );
	m_pInsaneMIF = CCMenuItemFont::create ( "Insane", this, menu_selector ( Ch3_SavingSimpleData::chooseInsane ) );

	CCMenu*		pMainMenu = CCMenu::create ( m_pEasyMIF, m_pMediumMIF, m_pHardMIF, m_pInsaneMIF, KD_NULL );
	pMainMenu->alignItemsVertically ( );
	pMainMenu->setPosition ( ccp ( 240, 140 ) );
	this->addChild ( pMainMenu, 1 );	
	
	// Load any previously chosen difficulty
	this->loadDifficulty ( );

	return KD_TRUE;
}
示例#4
0
void AboutLayer::setupViews(){

    setBackgroundImage( "loading.png" );
    
    //  加入title
    CCSprite* title = CCSprite::create( "menuTitle.png",CCRectMake(0, 34, 130, 38) );
    
    title->setAnchorPoint( ccp(0.5, 1) );
    title->setPosition( ccp( getWinSize().width / 2 ,getWinSize().height -20 ) );
    this->addChild( title );
    //  加入文字说明
    
    CCLabelBMFont* pDes = CCLabelBMFont::create( "This Game is recoded by longlingxiu ", "arial-14.fnt" );
    
    pDes->setPosition( ccp(getWinSize().width / 2, getWinSize().height / 2) );
    
    this ->addChild(pDes);
    
    
    
    CCLabelBMFont* fontOfBack = CCLabelBMFont::create("Go Back", "arial-14.fnt" );
    
    fontOfBack->setScale(1.5f);
    
    CCMenuItemLabel* backLabel = CCMenuItemLabel::create(fontOfBack, this, menu_selector(AboutLayer::back_callback));
    backLabel->setAnchorPoint( ccp( 0.5, 0 ) );
    backLabel->setPosition( ccp( getWinSize().width / 2, 30) );
    
    CCMenu* menu = CCMenu::create( backLabel, NULL );;
    menu->setPosition( CCPointZero );
    
    this->addChild( menu );
    
}
void PauseLayer::addObjectiveLayer() {
    objectiveLayer = CCLayer::create();
    objectiveLayer->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
    float scale = Utility::isIPad() ? 1 : 0.8;
    CCLabelBMFont *labelObj = CCLabelBMFont::create("objectives", kFontChubby, 0);
    labelObj->setPosition(ccp(winSize.width * 0, winSize.height * 0.45));
    labelObj->setScale(scale);
    objectiveLayer->addChild(labelObj, 2);
    
    createButton("btnStats.png", 5, ccp(winSize.width * 0.3, winSize.height * 0.93));
    
    int j = 0;
        arrayForActive = CCArray::create();
    for (int i = 1; i <= 41; i++) {
        //        int level = 40 - i;
        
        if (Utility::getAchievementStatus(i) == 1) {
            arrayForActive->insertObject(CCString::createWithFormat("%d", i), j);
            j++;
            if (j == 3) {
                break;
            }
        }
    }
    
    for (int i = 0; i < arrayForActive->count(); i++) {
        CCSprite *objective = CCSprite::createWithSpriteFrameName(kScrollBar);
        objective->setPositionY(winSize.height * kScrollBarGap * i - winSize.height * 0.2);
        
        CCString *string = (CCString*)arrayForActive->objectAtIndex(i);
        int level = string->intValue();
        CCString *obj_1 = (CCString*) Utility::objectiveDict()->valueForKey(CCString::createWithFormat("kAchievement_%d_0", level)->getCString());
        CCString *obj_2 = (CCString*) Utility::objectiveDict()->valueForKey(CCString::createWithFormat("kAchievement_%d_1", level)->getCString());
        createLabel(obj_1->getCString(), obj_2->getCString(), ccp(objective->getContentSize().width * 0.18, objective->getContentSize().height * 0.85), objective);
        createSprite("iconTrophy.png", ccp(objective->getContentSize().width * 0.03, objective->getContentSize().height * 0.85), objective);
        objectiveLayer->addChild(objective, 2);
    }
    addChild(objectiveLayer, 2);
    arrayForActive->removeAllObjects();
    arrayForActive->release();
    
    
    soundOn = CCSprite::createWithSpriteFrameName("btnSoundOn.png");
    menuItemSoundOn = CCMenuItemSprite::create(soundOn, soundOn, this, menu_selector(PauseLayer::soundsButtonTapped));
    menuItemSoundOn->setTag(1);
    
    soundOff = CCSprite::createWithSpriteFrameName("btnSoundOff.png");
    menuItemSoundOff = CCMenuItemSprite::create(soundOff, soundOff, this, menu_selector(PauseLayer::soundsButtonTapped));
    menuItemSoundOff->setTag(2);
    
    CCMenuItemToggle *toggleSound = CCMenuItemToggle::createWithTarget(this, menu_selector(PauseLayer::soundsButtonTapped), menuItemSoundOn, menuItemSoundOff, NULL);
    toggleSound->setSelectedIndex((CCUserDefault::sharedUserDefault()->getBoolForKey(kSoundsKey) ? 0 : 1));
    
    menuSoundOff = CCMenu::create(toggleSound , NULL);
    menuSoundOff->setPosition(ccp(winSize.width * 0.95, winSize.height * 0.92));
    addChild(menuSoundOff, 2);
}
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);
}
示例#7
0
// on "init" you need to initialize your instance
bool MainMenu::init()
{
	//////////////////////////////
	// 1. super init first
	if ( !CCLayer::init() )
	{
		return false;
	}

	// ask director the window size
	CCSize size = CCDirector::sharedDirector()->getWinSize();
	float scale = MultiResolution::getScale();
	/////////// Menu ////////////
	CCLabelBMFont* labelStart = CCLabelBMFont::create("Start", "futura-48.fnt");
	CCMenuItemLabel* pStartItem = CCMenuItemLabel::create(labelStart, this, menu_selector(MainMenu::menuStartCallback));
	pStartItem->setPosition(ccp(size.width/2, size.height/2));
	pStartItem->setScale(scale);

	CCLabelBMFont* labelOptions = CCLabelBMFont::create("Options", "futura-48.fnt");
	CCMenuItemLabel *pOptionsItem = CCMenuItemLabel::create(labelOptions, this, menu_selector(MainMenu::menuOptionsCallback));
	pOptionsItem->setPosition(ccp(size.width/2, size.height/2 - pStartItem->getContentSize().height*scale));
	pOptionsItem->setScale(scale);

	CCLabelBMFont* labelExit = CCLabelBMFont::create("Exit", "futura-48.fnt");
	CCMenuItemLabel *pExitItem = CCMenuItemLabel::create(labelExit, this, menu_selector(MainMenu::menuCloseCallback));
	pExitItem->setPosition(ccp(size.width/2, size.height/2 - 2*pStartItem->getContentSize().height*scale));
	pExitItem->setScale(scale);

	CCMenu* pMenu = CCMenu::create(pStartItem, pOptionsItem, pExitItem, NULL);
	pMenu->setPosition( CCPointZero );
	this->addChild(pMenu, 1);
	/////////////////////////////

	//////////// Game title and background image  ////////////
	CCLabelBMFont* pLabel = CCLabelBMFont::create("Crack Code", "futura-48.fnt");

	// position the label on the center of the screen
	pLabel->setPosition( ccp(size.width / 2, size.height - 50*scale) );
	pLabel->setScale(scale+0.3);

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

	// add "MainMenu" splash screen"
	CCSprite* pSprite = CCSprite::create("safe_background.jpg");

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

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

	return true;
}
示例#8
0
void TimeLayer::setView(){
	do{
		CCSize size=CCDirector::sharedDirector()->getWinSize();
		CCLabelBMFont* timerFont = CCLabelBMFont::create("Time:0","arial-14.fnt",35);
		//timerFont->setAnchorPoint(CCPointZero);
		timerFont->setPosition(ccp(size.width/2,size.height-100));
		timerFont->setScale(1.5f);
		this->addChild( timerFont,0,15 );
		//加入计时的定时任务
		this->schedule(schedule_selector(TimeLayer::time_counting_down),1.0f);	
	}while(0);

}
示例#9
0
Issue1343::Issue1343()
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCLabelBMFont* bmFont = new CCLabelBMFont();
    bmFont->init();
    bmFont->setFntFile("fonts/font-issue1343.fnt");
    bmFont->setString("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'");
    this->addChild(bmFont);
    bmFont->release();
    bmFont->setScale(0.3f);

    bmFont->setPosition(ccp(s.width/2,s.height/4*2));
}
示例#10
0
void TimeLayer::setupViews()
{
	do
	{
		CCLabelBMFont* pFnt = CCLabelBMFont::create("Time : 0s", "arial-14.fnt");
		pFnt->setAnchorPoint(CCPointZero);
		pFnt->setPosition(ccp(0, 0));
		pFnt->setScale(1.5);
		addChild(pFnt, 0, TIME_BM_FONT_TAG);

		schedule(schedule_selector(TimeLayer::tmWaste_Func), 1.0f);
	}
	while(0);
	
}
void GameLotteryLayer::initBackBtn()
{
	CCSprite* ptrBtnMenuBackNormal = CREATE_SPRITE(this,"game_lottery_arrow.png",false);
	m_ptrMenuBack = ScaleMenuItemSprite::create(ptrBtnMenuBackNormal, ptrBtnMenuBackNormal, 
		this, menu_selector(GameLotteryLayer::onBtnBackCallback),1.0f,1.1f);
	m_ptrBg->addChild(m_ptrMenuBack);
	LayoutUtil::layoutParentTop(m_ptrMenuBack, 0, 132);
	registerMenuItem(m_ptrMenuBack);

	CCLabelBMFont* ptrLbSpin = CCLabelBMFont::create(LOCALIZED_STRING("menu_lottery"),
		FontConstant::BMFONT_GOTHIC725_BLK_BT_BLUE);
	ptrLbSpin->setScale(0.375f);
	m_ptrMenuBack->addChild(ptrLbSpin);
	LayoutUtil::layoutParentTop(ptrLbSpin,3,-18);
}
示例#12
0
//  对控件以及布景 进行初始化
void OptionLayer::setupViews(){
    
    //  加入背景图片
    
    setBackgroundImage( "loading.png" );
    
    //  加入menutitle
    CCSprite* title = CCSprite::create( "menuTitle.png",CCRectMake(0, 0, 133, 36) );
    
    title->setAnchorPoint( ccp(0.5, 1) );
    title->setPosition( ccp( getWinSize().width / 2 ,getWinSize().height -20 ) );
    this->addChild( title );
    
    //  加入menu-- 既是创建CCMenuItemToggle
    CCMenuItemToggle* music_trigger = CCMenuItemToggle::createWithTarget(this, menu_selector(OptionLayer::music_trigger_callback), CCMenuItemFont::create( "Music : On" ),CCMenuItemFont::create("Music : Off"),NULL);
    
    music_trigger->setPosition( ccp( getWinSize().width / 2 ,getWinSize().height / 2 ) );
    //  根据背景音乐播放与否来显示相关的文字选项
    
    if( SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying() )
    {
              
        music_trigger->setSelectedIndex( 1 );
        
    }
    else
    {
        music_trigger->setSelectedIndex( 0 );
        
    }
    
    //  创建后退的CCMenuItem
    CCLabelBMFont* fontOfBack = CCLabelBMFont::create("Go Back", "arial-14.fnt" );
    
    fontOfBack->setScale(1.5f);
    
    CCMenuItemLabel* backLabel = CCMenuItemLabel::create(fontOfBack, this, menu_selector(OptionLayer::back_callback));
    backLabel->setAnchorPoint( ccp( 0.5, 0 ) );
    backLabel->setPosition( ccp( getWinSize().width / 2, 30) );
    
    
    CCMenu* menu = CCMenu::create( music_trigger,backLabel,NULL);
    
    menu ->setPosition( CCPointZero );
//    menu->setPosition( ccp( getWinSize().width / 2, getWinSize().height /  2) );
    
    this->addChild( menu );
}
示例#13
0
// on "init" you need to initialize your instance
bool LevelChooser::init()
{
	//////////////////////////////
	// 1. super init first
	if ( !CCLayer::init() )
	{
		return false;
	}

    CodeChecker::initLevels();
    
	// ask director the window size
	CCSize size = CCDirector::sharedDirector()->getWinSize();

	float scale = MultiResolution::getScale();
	CCLabelBMFont* pLabel = CCLabelBMFont::create("Select Level", "futura-48.fnt");
	pLabel->setPosition( ccp(size.width / 2, size.height - 50*scale) );
	pLabel->setScale(MultiResolution::getScale());
	this->addChild(pLabel, 1);

	LevelLayer *level1 = new LevelLayer("lvl1.png", 1);
	LevelLayer *level2 = new LevelLayer("lvl2.png", 2);
	LevelLayer *level3 = new LevelLayer("lvl3.png", 3);
	LevelLayer *level4 = new LevelLayer("lvl4.png", 4);

    CCArray layers;
	layers.addObject(level1);
    layers.addObject(level2);
    layers.addObject(level3);
    layers.addObject(level4);

    pScrollLevelLayer = CCScrollLayer::layerWithLayers(&layers, 160, 60);
    this->addChild(pScrollLevelLayer,1);
	
	CCLabelBMFont * pLabel1 = CCLabelBMFont::create( "go back", "futura-48.fnt" );
	CCMenuItemLabel * pBack = CCMenuItemLabel::create(pLabel1, this, menu_selector(LevelChooser::backCallback));
	CCMenu* pMenu = CCMenu::create(pBack, NULL);
    pMenu->setPosition(ccp(size.width - 100, 50));

	this->addChild(pMenu, 1);

	CCSprite* pSprite = CCSprite::create("safe_background.jpg");
	pSprite->setPosition( ccp(size.width / 2, size.height / 2) );
	this->addChild(pSprite, 0);
	return true;
}
示例#14
0
bool PauseLayer:: init(GameLayer *gameLayer) {
    if (!CCLayer::init()) {
        return false;
    }
    float scale = Utility::isIPad() ? 1 : 0.5;
    gLayer = gameLayer;
    charMenuIemList = new CCArray;
//    Utility::addSpriteSheet("buttonTexture");
    isCallFromRecords = true;
    
    winSize = CCDirector::sharedDirector()->getWinSize();
    CCLayerColor *colorLayer = CCLayerColor::create(ccc4(50, 50, 50, 100), winSize.width  , winSize.height );
    addChild(colorLayer);
    
    if (gameLayer->sceneType == kSceneTypeGameScene) {
        addMenuItems("btnNewGame.png", 1);   
    }
    addMenuItems("btnMenu.png", 2);
    
    CCMenu *btnMenu = CCMenu::createWithArray(charMenuIemList);
    btnMenu->alignItemsHorizontallyWithPadding(winSize.width * 0.05);
    btnMenu->setPosition(ccp(winSize.width * 0.2, winSize.height * 0.1));
    addChild(btnMenu, 2);

    CCSprite *iconStar = CCSprite::createWithSpriteFrameName("coinsStars_4.png");
    iconStar->setScale(0.8);
    iconStar->setPosition(ccp(winSize.width * 0.05, winSize.height * 0.92));
    addChild(iconStar, 2);
    
    const char *totalStars = CCString::createWithFormat("%d", Utility::getTotalStars())->getCString();
    CCLabelBMFont *starsLabel = CCLabelBMFont::create(totalStars, kFontChubby, 0);
    starsLabel->setPosition(ccp(iconStar->getPositionX() + winSize.width * 0.05, winSize.height * 0.92));
    starsLabel->setScale(scale);
    addChild(starsLabel, 2);
    
    addObjectiveLayer();
    hideHUDButtons();
    //add resume button

    createButton("btnResume.png", 3, ccp(winSize.width * 0.9, winSize.height * 0.1));
//    createButton("btnSound.png", 4, ccp(winSize.width * 0.95,winSize.height * 0.92));
    return true;
}
void GameScene::showScore() {
	//スコア
	CCLabelBMFont* score = dynamic_cast<CCLabelBMFont*>(this->getChildByTag(
			kTagScore));
	if (score) {
		score->removeFromParent();
	}

	CCLabelBMFont* label = dynamic_cast<CCLabelBMFont*>(this->getChildByTag(
			kTagScoreLabel));

	CCString* gameScore = CCString::createWithFormat("%d", getScore());
	score = CCLabelBMFont::create(gameScore->getCString(), FONT_ORANGE);
	score->setScale(TEXT_SCALE);
	score->setAnchorPoint(CCPointZero);
	score->setPosition(
			label->getPositionX() + label->getContentSize().width * TEXT_SCALE
					+ 10, label->getPositionY());
	score->setTag(kTagScore);
	this->addChild(score);
}
void GameScene::showBallRemain() {
	//残りボール数
	CCLabelBMFont* remain = dynamic_cast<CCLabelBMFont*>(this->getChildByTag(
			kTagBallRemainCount));
	if (remain) {
		this->removeChild(remain);
	}

	CCLabelBMFont* label = dynamic_cast<CCLabelBMFont*>(this->getChildByTag(
			kTagBallRemainLabel));

	CCString* ballRemain = CCString::createWithFormat("%d", getBallRemain());
	remain = CCLabelBMFont::create(ballRemain->getCString(), FONT_ORANGE);
	remain->setScale(TEXT_SCALE);
	remain->setAnchorPoint(CCPointZero);
	remain->setPosition(
			label->getPositionX() + label->getContentSize().width * TEXT_SCALE
					+ 10, label->getPositionY());
	remain->setTag(kTagBallRemainCount);
	this->addChild(remain);
}
示例#17
0
KDvoid CScrGame::onEnterTransitionDidFinish ( KDvoid )
{
	CCLayer::onEnterTransitionDidFinish ( );

    CCFiniteTimeAction*  pAction = CCSequence::create 
    (
        CCSpawn ::create ( CCScaleTo ::create ( 0.7f, 3 ), CCFadeIn::create  ( 0.7f ), KD_NULL ),
        CCRepeat::create ( CCSequence::create ( CCFadeOut::create ( 0.5f ), CCFadeIn ::create ( 0.5f ), KD_NULL ), 3 ),
        CCSpawn ::create ( CCScaleTo ::create ( 0.7f, 10 ), CCFadeOut::create ( 0.7f ), KD_NULL ),     
        CCCallFuncN::create ( this, callfuncN_selector ( CScrGame::onStart ) ), 
        CCCallFuncN::create ( this, callfuncN_selector ( CScrGame::onRemove ) ), 
        KD_NULL
    );
    
    CCLabelBMFont*   pStart = g_pResMgr->getLabel ( this, "Game Start !!!" );
    
    pStart->setPosition ( ccpMid ( CCDirector::sharedDirector ( )->getWinSize ( ) ) );
    pStart->setScale ( 10 );
    pStart->setOpacity ( 0 );
    pStart->runAction ( pAction );
}
示例#18
0
void HelloWorld::endScene( EndReason endReason ) {
	if (_gameOver)
		return;

    _gameOver = true;

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

    /*
    char message[10] = "You Win";
    if ( endReason == KENDREASONLOSE)
        strcpy(message,"You Lose");
    */

    char message[12] = { 0 };
    sprintf(message, "Score: %d", _score);

    CCLabelBMFont * label ;
    label = CCLabelBMFont::create(message, "fonts/Arial.fnt");
    label->setScale(0.1);
    label->setPosition(ccp(winSize.width/2 , winSize.height*0.6));
    this->addChild(label);

    CCLabelBMFont * restartLabel;
    strcpy(message,"Restart");
    restartLabel = CCLabelBMFont::create(message, "fonts/Arial.fnt");
    CCMenuItemLabel *restartItem = CCMenuItemLabel::create(restartLabel, this, menu_selector(HelloWorld::restartTapped) );
    restartItem->setScale(0.1);
    restartItem->setPosition( ccp(winSize.width/2, winSize.height*0.4));

    CCMenu *menu = CCMenu::create(restartItem, NULL);
    menu->setPosition(CCPointZero);
    this->addChild(menu);

    // clear label and menu
    restartItem->runAction(CCScaleTo::create(0.5, 1.0));
    label ->runAction(CCScaleTo::create(0.5, 1.0));
    // Terminate update callback
    this->unscheduleUpdate();
}
示例#19
0
void OptionLayer::setViews()
{
	setBackGroundImage("loading.png");	

	CCSprite *title = CCSprite::create("menuTitle.png",CCRectMake(0,0,135,35));
	title->setAnchorPoint(ccp(0.5,1));
	title->setPosition(ccp(getWinSize().width/2,getWinSize().height-20));

	this->addChild(title);

	CCMenuItemToggle *music_trigger = CCMenuItemToggle::createWithTarget(this,menu_selector(OptionLayer::music_triggerCallback),
			CCMenuItemFont::create("Music : On"),CCMenuItemFont::create("Music : Off"),NULL);
	
	music_trigger->setPosition(ccp(getWinSize().width/2,getWinSize().height/2));


	if(SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying())
	{
		music_trigger->setSelectedIndex(1);
	}
	else
	{
		music_trigger->setSelectedIndex(0);
	}

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

	CCLabelBMFont *back = CCLabelBMFont::create("back","arial-14.fnt");

	back->setScale(1.25f);
	CCMenuItemLabel *backLable =  CCMenuItemLabel::create(back,this,menu_selector(OptionLayer::backCallback));
	backLable->setAnchorPoint(ccp(0.5,1));
	backLable->setPosition(ccp(getWinSize().width/2,50));

	CCMenu *menu = CCMenu::create(music_trigger,backLable,NULL);
	menu->setPosition(CCPointZero);

	this->addChild(menu);
}
示例#20
0
void CommonButton::setFontSize(float fontSize) {
	CCLabelBMFont *  bmFont = dynamic_cast<CCLabelBMFont * >(m_label);
	CCLabelBMFont *  bmFont1 = dynamic_cast<CCLabelBMFont * >(m_pBottomlabel);
    
	if (bmFont) {
		float scale = fontSize/24;
		bmFont->setScale(scale);
	} else {
		CCLabelTTF *  ttf = dynamic_cast<CCLabelTTF * >(m_label);
		if (ttf) {
			ttf->setFontSize(fontSize);
		}
	}
    
	if (bmFont1) {
		float scale = fontSize/24;
		bmFont1->setScale(scale);
	} else {
		CCLabelTTF *  ttf = dynamic_cast<CCLabelTTF * >(m_pBottomlabel);
		if (ttf) {
			ttf->setFontSize(fontSize);
		}
	}
}
示例#21
0
void WordPuzzleLayer::didCorrectCharacterSelected(CCArray* wordIdxArray, int index)
{
	//맥스 콤보 업데이트
	combo++;
	if (report.maxCombo < combo) 
	{
		report.maxCombo = combo;
	}
	
	SimpleAudioEngine::sharedEngine()->playEffect("sound/main_card_popup.mp3");
	char buf[20];
	
	CCSprite* sprMultiplier;
	
	if (combo < 5) 
	{
		sprMultiplier = NULL;
		multiplier = 1;
	}
	else if (combo < 10)
	{
		// x2
#if (defined PD_IPHONE) || (defined ANDROID_PHONE)
		sprMultiplier = CCSprite::spriteWithFile(__CONFIG_IMAGE_PATH_GAME__("effect/game_double_01.png"));
#else
		sprMultiplier = CCSprite::spriteWithFile("game/effect/game_double_01.png");
#endif
		multiplier = 2;
	}
	else if (combo < 20)
	{
		// x4
#if (defined PD_IPHONE) || (defined ANDROID_PHONE)
		sprMultiplier = CCSprite::spriteWithFile(__CONFIG_IMAGE_PATH_GAME__("effect/game_double_02.png"));
#else
		sprMultiplier = CCSprite::spriteWithFile("game/effect/game_double_02.png");
#endif
		
		multiplier = 4;
	}
	else if (combo < 30)
	{
		// x8
#if (defined PD_IPHONE) || (defined ANDROID_PHONE)
		sprMultiplier = CCSprite::spriteWithFile(__CONFIG_IMAGE_PATH_GAME__("effect/game_double_03.png"));
#else
		sprMultiplier = CCSprite::spriteWithFile("game/effect/game_double_03.png");
#endif
		multiplier = 8;
	}
	else if (combo < 50)
	{
		// x16
#if (defined PD_IPHONE) || (defined ANDROID_PHONE)
		sprMultiplier = CCSprite::spriteWithFile(__CONFIG_IMAGE_PATH_GAME__("effect/game_double_04.png"));	
#else
		sprMultiplier = CCSprite::spriteWithFile("game/effect/game_double_04.png");	 
#endif
		
		multiplier = 16;
	}
	else 
	{
#if (defined PD_IPHONE) || (defined ANDROID_PHONE)
		sprMultiplier = CCSprite::spriteWithFile(__CONFIG_IMAGE_PATH_GAME__("effect/game_double_05.png"));	 
#else
		sprMultiplier = CCSprite::spriteWithFile("game/effect/game_double_05.png");	 
#endif
		
		multiplier = 32;
	}


#if (defined PD_IPHONE) || (defined ANDROID_PHONE)
	CCSprite* label = CCSprite::spriteWithFile(__CONFIG_IMAGE_PATH_GAME__("effect/game_up.png"));
#else
	CCSprite* label = CCSprite::spriteWithFile("game/effect/game_up.png");
#endif
	
	label->setPosition(pointLabelPosition);
	this->addChild(label, 9999);
	
	if (sprMultiplier) 
	{
		sprMultiplier->setAnchorPoint(ccp(0,0.5));
#if (defined PD_IPHONE) || (defined ANDROID_PHONE)
		sprMultiplier->setPosition(ccp(label->getContentSize().width - 5,35));
#else
		sprMultiplier->setPosition(ccp(175,35));
#endif
		label->addChild(sprMultiplier);
	}


	
	label->setScale(0.2);
	
	CCEaseExponentialOut * fadeout = CCEaseExponentialOut::actionWithAction( CCActionTween::actionWithDuration(1.5,"opacity",255,0) );
	CCCallFuncN* callfunc = CCCallFuncN::actionWithTarget(this, callfuncN_selector(WordPuzzleLayer::onPointLabelFadeOut));
	
	label->runAction(CCMoveBy::actionWithDuration(0.8, ccp(0,100)));
	label->runAction(CCEaseBounceInOut::actionWithAction(CCScaleTo::actionWithDuration(0.3,labelScaleTo)));
	label->runAction(CCSequence::actions(CCDelayTime::actionWithDuration(0.7),fadeout,callfunc, NULL));

	
	if (combo > 2)
	{
		sprintf(buf, "%dCombo",combo);
		CCLabelBMFont* lblCombo = (CCLabelBMFont*)getChildByTag(TAG_COMBO);
		
		CCEaseExponentialOut * fadeout = CCEaseExponentialOut::actionWithAction( CCActionTween::actionWithDuration(1.5,"opacity",255,0) );
		CCCallFuncN* callfunc = CCCallFuncN::actionWithTarget(this, callfuncN_selector(WordPuzzleLayer::onPointLabelFadeOut));
		
		if (lblCombo)
		{
			lblCombo->setString(buf);
			
			lblCombo->stopAllActions();
			lblCombo->setOpacity(255);
			lblCombo->setPosition(comboLabelPosition);

			lblCombo->setScale(0.2);			
			lblCombo->runAction(CCEaseBounceInOut::actionWithAction(CCScaleTo::actionWithDuration(0.3,labelScaleTo)));
			lblCombo->runAction(CCSequence::actions(CCDelayTime::actionWithDuration(1.5),fadeout,callfunc, NULL));
		}
		else
		{
			lblCombo = CCLabelBMFont::labelWithString(buf, "font/combo.fnt");
			lblCombo->setPosition(comboLabelPosition);
			
			this->addChild(lblCombo, 9999, TAG_COMBO);
			
			lblCombo->setScale(0.2);			
			lblCombo->runAction(CCEaseBounceInOut::actionWithAction(CCScaleTo::actionWithDuration(0.3,labelScaleTo)));
			lblCombo->runAction(CCSequence::actions(CCDelayTime::actionWithDuration(1.5),fadeout,callfunc, NULL));
		}
	}

		
	
}
示例#22
0
void RankScene::rankListDraw(int _tibaoType){

    tableIndex = 1;
    
    //1.主框体底板
    CCSprite* ranklistTable = CCSprite::createWithSpriteFrameName("ranklistTable.png");
    ranklistTable->setPosition(ccp(size.width/2, size.height/2+winDif*alpha*alpha));
    layerToRoll->addChild(ranklistTable,1);
    
    //2.两个模式的排行榜按钮
    CCSprite* RankListTitle = CCSprite::createWithSpriteFrameName("RankListTitle.png");
    RankListTitle->setPosition(ccp(size.width/2,size.height*1605/1700+winDif*alpha*alpha));
    layerToRoll->addChild(RankListTitle,4,9);
    
    //3.下面四个按钮
    CCSprite* backButtonSprite = CCSprite::createWithSpriteFrameName("back_rank.png");
    CCSprite* backButtonSprite_s = CCSprite::createWithSpriteFrameName("back-s_rank.png");
    CCSprite* inviteButtonSprite = CCSprite::createWithSpriteFrameName("invite_rank.png");
    CCSprite* inviteButtonSprite_s = CCSprite::createWithSpriteFrameName("invite-s_rank.png");
    CCSprite* shareButtonSprite = CCSprite::createWithSpriteFrameName("shareButton_rank.png");
    CCSprite* shareButtonSprite_s = CCSprite::createWithSpriteFrameName("shareButton-s_rank.png");
    CCSprite* ListListButtonSprite = CCSprite::createWithSpriteFrameName("ListListButton.png");
    CCSprite* ListListButtonSprite_s = CCSprite::createWithSpriteFrameName("ListListButton-s.png");
    CCMenuItemSprite* backButton = CCMenuItemSprite::create(backButtonSprite,backButtonSprite_s,this,menu_selector(RankScene::backToTibaoSelection));
    CCMenuItemSprite* inviteButton = CCMenuItemSprite::create(inviteButtonSprite,inviteButtonSprite_s,this,menu_selector(RankScene::inviteFriends));
    CCMenuItemSprite* shareButton = CCMenuItemSprite::create(shareButtonSprite,shareButtonSprite_s,this,menu_selector(RankScene::shareRank));
    CCMenuItemSprite* ListListButton = CCMenuItemSprite::create(ListListButtonSprite,ListListButtonSprite_s,this,menu_selector(RankScene::goToRankListList));
    backButton->setPosition(ccp(size.width*111/700,size.height*1017/2200+winDif*alpha*alpha));
    inviteButton->setPosition(ccp(size.width*272/700, size.height*1017/2200+winDif*alpha*alpha));
    shareButton->setPosition(ccp(size.width*430/700, size.height*1017/2200+winDif*alpha*alpha));
    ListListButton->setPosition(ccp(size.width*589/700, size.height*1017/2200+winDif*alpha*alpha));
    backButton->setTag(11);
    inviteButton->setTag(12);
    shareButton->setTag(13);
    ListListButton->setTag(14);
    bottomMenu = CCMenu::create(backButton,inviteButton,shareButton,ListListButton,NULL);
    bottomMenu->setPosition(CCPointZero);
    layerToRoll->addChild(bottomMenu,3,10);
    
    //4.上面的遮罩板
    CCSprite* rankListCover = CCSprite::createWithSpriteFrameName("rankListCover.png");
    rankListCover->setPosition(ccp(size.width*249/500,size.height*327/360+winDif*alpha*alpha));
    layerToRoll->addChild(rankListCover,3);
    
    //5.几天后结算
    daysLeftLabel = CCLabelTTF::create("0天 后结算本周排名", "Arial Rounded", 17);
    daysLeftLabel->setPosition(ccp(size.width/2, size.height*320/360+winDif*alpha*alpha));
    layerToRoll->addChild(daysLeftLabel,4,16);
    
    //6.题包名称
    CCLabelBMFont* rankName = CCLabelBMFont::create(tibaoName[_tibaoType].c_str(), "puzzlename_list2.fnt");
    rankName->setScale(0.417);
    rankName->setPosition(ccp(size.width/2, size.height*1710/1800+winDif*alpha*alpha));
    layerToRoll->addChild(rankName,5,15);
    
    //7.设置scrollview
    ContainerLayer = CCLayerColor::create(ccc4(0,0,0,0));
    ContainerLayer->setContentSize(CCSizeMake(size.width, size.height*2.14));
    ContainerLayer->setPosition(ccp(0,-size.height*1.675+winDif/130*alpha));

    //8. 1-21名的格子
    for(int i = 0 ; i < 20 ; i++){
        CCSprite* RankTable = CCSprite::createWithSpriteFrameName("other_rank.png");
        RankTable->setPosition(ccp(size.width/2, size.height*2230/1120-size.height*i*63/660+winDif/130*alpha));
        ContainerLayer->addChild(RankTable,1,20+i);
    }
    
    //9.初始化scrollview
    CCScrollView* pScrollView = CCScrollView::create(CCSizeMake(size.width, size.height*358/768));
    pScrollView->setPosition(ccp(0, size.height/2+winDif*alpha*alpha));
    layerToRoll->addChild(pScrollView,1,999);
    pScrollView->isDragging();
    pScrollView->isTouchMoved();
    pScrollView->setBounceable(true);
    pScrollView->setContainer(ContainerLayer);
    pScrollView->getViewSize();
    pScrollView->updateInset();
    pScrollView->setTouchEnabled(true);
    pScrollView->setDelegate(this);
    pScrollView->setDirection(kCCScrollViewDirectionVertical);
}
示例#23
0
文件: HelpLayer.cpp 项目: xuqin/tgp
void HelpLayer::initUI()
{
	CCSize size = ToolsFun::sharedTools()->getSceneSize();

	//背景
	CCSprite * bkg = CCSprite::create("ui/shared/bkg.png");
	this->addChild(bkg, -4);
	bkg->setPosition(size / 2);

	//头部
	CCSprite *spBkgTop = CCSprite::create("ui/shared/top.png");
	this->addChild(spBkgTop, 0);
	spBkgTop->setPosition(ccp(size.width / 2, size.height - spBkgTop->getContentSize().height / 2));

	//金币放置最上方商城
	CCSprite *coinIcon = CCSprite::create("ui/shared/coin.png");
	this->addChild(coinIcon, 2, 1429);
	coinIcon->setPosition(ccp(280*gScaleX, size.height - 30*gScaleY));
	m_coinLabel = CCLabelBMFont::create("10000000", GOLD_FONT);
	this->addChild(m_coinLabel, 4);
	m_coinLabel->setAnchorPoint(ccp(0, 0.5f));
	m_coinLabel->setPosition(ccp(300*gScaleX, size.height - 25*gScaleY));
	m_coinLabel->setScale(0.6F);

	setCoin();

	CCMenu *menu = CCMenu::create();
	this->addChild(menu, 10);
	menu->setTouchPriority(-130);
	menu->setPosition(CCPointZero);
	CCSprite *spNml = CCSprite::create("ui/shared/back.png");
	CCSprite *spSel = CCSprite::create("ui/shared/back.png");
	spSel->setColor(ccc3(100, 100, 100));
	CCMenuItemSprite *spItem = CCMenuItemSprite::create(spNml, spSel, this, menu_selector(HelpLayer::back));
	menu->addChild(spItem);
	spItem->setPosition(ccp(37*gScaleX, size.height - 37*gScaleY));
	//show shop
	spNml = CCSprite::create("ui/shared/coinplus.png");
	spSel = CCSprite::create("ui/shared/coinplus.png");
	spSel->setColor(ccc3(100, 100, 100));
	spItem = CCMenuItemSprite::create(spNml, spSel, this, menu_selector(HelpLayer::showShopLayer));
	menu->addChild(spItem);
	spItem->setPosition(ccp(430*gScaleX, size.height - 30*gScaleY));

	//初始化宠物界面
	m_menu = CCMenu::create();
	m_uiNode->addChild(m_menu, 2);
	m_uiNode->setPosition(CCPointZero);
	m_menu->setPosition(CCPointZero);
	SK::StringKey nameKey[5] = {K.ITEM_NAME0, K.ITEM_NAME1, K.ITEM_NAME2, K.ITEM_NAME3, K.ITEM_NAME4};
	SK::StringKey desKey[5] = {K.ITEM_DES0, K.ITEM_DES1, K.ITEM_DES2, K.ITEM_DES3, K.ITEM_DES4};

	const char *fileName[5] = {"item/item2_0.png","item/item0_0.png","item/item1_0.png",
		"item/item3_0.png","item4_3.png"};

	for(int i = 0; i != 5; ++i)
	{
		CCSprite *petSprite = NULL;

		if(i ==4)
		{
			petSprite = CCSprite::createWithSpriteFrameName(fileName[i]);
		}
		else
		{
			petSprite  = CCSprite::create(fileName[i]);
		}
		m_uiNode->addChild(petSprite, 1);
		petSprite->setPosition(ccp(120*gScaleX, 130*gScaleY)+ccp(0,180*i));

		CCSprite* petDes = CCSprite::create("ui/petUI/pet_describe.png");
		m_uiNode->addChild(petDes, 1);
		petDes->setPosition(ccp(330*gScaleX, 140*gScaleY)+ccp(0,180*i));

		m_desFont[i] = CCLabelBMFont::create(gGetLanguageDesc(desKey[i]).c_str(), "font/item_des.fnt");
		m_uiNode->addChild(m_desFont[i], 10);
		m_desFont[i]->setPosition(ccp(240*gScaleX, 130*gScaleY)+ccp(0,180*i));
		m_desFont[i]->setAnchorPoint(CCPointZero);

		m_nameFont[i] = CCLabelBMFont::create(gGetLanguageDesc(nameKey[i]).c_str(), "font/item_des.fnt");
		m_uiNode->addChild(m_nameFont[i], 10);
		m_nameFont[i]->setPosition(ccp(240*gScaleX, 160*gScaleY)+ccp(0,180*i));
		m_nameFont[i]->setAnchorPoint(CCPointZero);
	
		CCLabelBMFont *nameLabel = m_nameFont[i];
		nameLabel->setScale(0.6f);
		nameLabel->setString(gGetLanguageDesc(nameKey[i]).c_str());

		CCLabelBMFont *desLabel = m_desFont[i];
		desLabel->setScale(0.6f);
		desLabel->setString(gGetLanguageDesc(desKey[i]).c_str()); 
	}
}
// Initialize our Main Menu Layer, and add the initial main menu with the title screen, play button and about button.
bool GameOverLayer::init()
{
    // Initialize the parent
    if (!CCLayer::init()) return false;
    
    // Load the high scores
    CCUserDefault *store = CCUserDefault::sharedUserDefault();
    int bestScore = store->getIntegerForKey("best-score", 0);
    int bestDistance = store->getIntegerForKey("best-distance", 0);
    int bestDifficulty = store->getIntegerForKey("best-difficulty", 0);
    bool newRecord = false;
    
    if (GameManager::sharedGameManager()->getScore() > bestScore && GameManager::sharedGameManager()->getDistance() > bestDistance)
    {
        bestScore = GameManager::sharedGameManager()->getScore();
        bestDistance = GameManager::sharedGameManager()->getDistance();
        bestDifficulty = GameManager::sharedGameManager()->getDifficulty();
        store->setIntegerForKey("best-score", bestScore);
        store->setIntegerForKey("best-distance", bestDistance);
        store->setIntegerForKey("best-difficulty", bestDifficulty);
        store->flush();
        newRecord = true;
    }
    
    // Set the screen size to the full dimensions of the device (full screen)
    this->setContentSize(SCREEN_SIZE);
    
    float labelScaleText = 1.2f;
    if (GameManager::sharedGameManager()->getDeviceType() == kDeviceTypeAndroid854x480 ||
        GameManager::sharedGameManager()->getDeviceType() == kDeviceTypeAndroid800x480 ||
        GameManager::sharedGameManager()->getDeviceType() == kDeviceTypeAndroid800x400 ||
        GameManager::sharedGameManager()->getDeviceType() == kDeviceTypeAndroid720x480)
    {
        labelScaleText = 0.9f;
    }
    else if (GameManager::sharedGameManager()->getDeviceSize() == kDeviceSizeNormal)
    {
        labelScaleText = 1.0f;
    }
    else if (GameManager::sharedGameManager()->getDeviceSize() == kDeviceSizeSmall)
    {
        labelScaleText = 0.5f;
    }
    
    CCSprite *gameOverTitle = CCSprite::createWithSpriteFrameName("game_over.png");
    gameOverTitle->setScale(0.9f);
    gameOverTitle->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.8));
    this->addChild(gameOverTitle);
    
    CCString *score = CCString::createWithFormat("YOUR SCORE: %i", GameManager::sharedGameManager()->getScore());
    CCLabelBMFont *scoreLabel = CCLabelBMFont::create(score->getCString(), "myGlyphs.fnt");
    scoreLabel->setScale(labelScaleText);
    scoreLabel->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.65));
    this->addChild(scoreLabel);
    
    CCString *distance = CCString::createWithFormat("YOUR DISTANCE: %i", GameManager::sharedGameManager()->getDistance());
    CCLabelBMFont *distanceLabel = CCLabelBMFont::create(distance->getCString(), "myGlyphs.fnt");
    distanceLabel->setScale(labelScaleText);
    distanceLabel->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.59));
    this->addChild(distanceLabel);
    
    CCString *ydifficulty;
    switch (GameManager::sharedGameManager()->getDifficulty())
    {
        case 3:
            ydifficulty = CCString::create("HARD");
            break;
        case 2:
            ydifficulty = CCString::create("MEDIUM");
            break;
        default:
            ydifficulty = CCString::create("EASY");
    }
    
    CCString *difficulty = CCString::createWithFormat("YOUR DIFFICULTY: %s", ydifficulty->getCString());
    CCLabelBMFont *difficultyLabel = CCLabelBMFont::create(difficulty->getCString(), "myGlyphs.fnt");
    difficultyLabel->setScale(labelScaleText);
    difficultyLabel->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.53));
    this->addChild(difficultyLabel);
    
    CCString *highScore = CCString::createWithFormat("HIGH SCORE: %i", bestScore);
    CCLabelBMFont *highScoreLabel = CCLabelBMFont::create(highScore->getCString(), "myGlyphs.fnt");
    highScoreLabel->setScale(labelScaleText);
    highScoreLabel->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.43));
    this->addChild(highScoreLabel);
    
    CCString *highDistance = CCString::createWithFormat("BEST DISTANCE: %i", bestDistance);
    CCLabelBMFont *highDistanceLabel = CCLabelBMFont::create(highDistance->getCString(), "myGlyphs.fnt");
    highDistanceLabel->setScale(labelScaleText);
    highDistanceLabel->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.37));
    this->addChild(highDistanceLabel);
    
    CCString *bdifficulty;
    switch (bestDifficulty)
    {
        case 3:
            bdifficulty = CCString::create("HARD");
            break;
        case 2:
            bdifficulty = CCString::create("MEDIUM");
            break;
        default:
            bdifficulty = CCString::create("EASY");
    }
    
    CCString *highDifficulty = CCString::createWithFormat("DIFFICULTY: %s", bdifficulty->getCString());
    CCLabelBMFont *highDifficultyLabel = CCLabelBMFont::create(highDifficulty->getCString(), "myGlyphs.fnt");
    highDifficultyLabel->setScale(labelScaleText);
    highDifficultyLabel->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT*0.31));
    this->addChild(highDifficultyLabel);
    
    // Play again button
    createPlayAgainButton();
    
    // Play Game Over Sound
    CocosDenshion::SimpleAudioEngine::sharedEngine()->setEffectsVolume(1.0f);
    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("sfx_gameover.mp3", false);
    
    // Do new record animation
    if (newRecord)
    {
        // TODO
    }
    
    // Initialization was successful
    return true;
}
示例#25
0
void PauseLayer::addStatsLayer() {
    statsLayer = CCLayer::create();
    statsLayer->setPosition(ccp(winSize.width * 0, winSize.height * 0));
    float scale = Utility::isIPad() ? 1 : 0.7;
    CCLabelBMFont *labelObj = CCLabelBMFont::create("stats", kFontChubby, 0);
    labelObj->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.93));
    labelObj->setScale(scale);
    statsLayer->addChild(labelObj, 2);
    
    CCLabelBMFont *thisGameLabel = CCLabelBMFont::create("this game", kFontChubby, 0);
    thisGameLabel->setScale(scale);
    thisGameItem = CCMenuItemLabel::create(thisGameLabel, this, menu_selector(PauseLayer::menuCallBack) );
    thisGameItem->setContentSize(CCSize(thisGameItem->getContentSize() * scale));
    thisGameItem->setTag(7);
    
    CCLabelBMFont *slashLabel = CCLabelBMFont::create("/", kFontChubby, 0);
    slashLabel->setScale(scale);
    CCMenuItemLabel *slashItem = CCMenuItemLabel::create(slashLabel, this, menu_selector(PauseLayer::menuCallBack) );
    slashItem->setContentSize(CCSize(slashItem->getContentSize() * scale));
    
    CCLabelBMFont *recordsLabel = CCLabelBMFont::create("records", kFontChubby, 0);
    recordsLabel->setScale(scale);
    recordsItem = CCMenuItemLabel::create(recordsLabel, this, menu_selector(PauseLayer::menuCallBack) );
    recordsItem->setContentSize(CCSize(recordsItem->getContentSize() * scale));
    recordsItem->setTag(8);

    
    CCMenu *thisGameRecordsMenu = CCMenu::create(thisGameItem, slashItem, recordsItem, NULL);
    thisGameRecordsMenu->alignItemsHorizontallyWithPadding(winSize.width * 0.01);
    thisGameRecordsMenu->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.8));
    statsLayer->addChild(thisGameRecordsMenu, 2);
    
    createButton("btnObj.png", 6, ccp(winSize.width * 0.30, winSize.height * 0.93));
    const char *score = NULL;
    const char *distance = NULL;
    const char *wallsSmashed = NULL;
    const char *tightSqueezes = NULL;
    const char *longestGamePlayed = NULL;
    if (isCallFromRecords) {
        CCSprite *coinSprite = CCSprite::createWithSpriteFrameName("coin_0.png");
        coinSprite->setPosition(ccp(winSize.width * 0.75, winSize.height * 0.65));
        statsLayer->addChild(coinSprite, 2);
        
        const char *totalCoins = CCString::createWithFormat("%d", gLayer->coinScore)->getCString();
        createLabelForStats("", totalCoins, ccp(coinSprite->getPositionX() + winSize.width * 0.05, coinSprite->getPositionY()), statsLayer);
        
        score =  CCString::createWithFormat("%d", gLayer->score)->getCString();
        distance =  CCString::createWithFormat("%d meters", gLayer->distance)->getCString();
        wallsSmashed =  CCString::createWithFormat("%d", gLayer->wallSmashed)->getCString();
        tightSqueezes =  CCString::createWithFormat("%d", Utility::getTotalTightSqueezes())->getCString();
        longestGamePlayed = CCString::createWithFormat("%02dm%02ds", gLayer->minute, gLayer->seconds)->getCString();
    } else {
        const char *playerName = CCString::createWithFormat("(%s)", Utility::getPlayerName(0)->getCString())->getCString();
        createLabelForStats("", playerName, ccp(winSize.width * 0.65, winSize.height * 0.65), statsLayer);
        int longestGame = Utility::getLongestGame();
        int min = longestGame / 60;
        int sec = longestGame % 60;
        longestGamePlayed = CCString::createWithFormat("%02dm%02ds", min, sec)->getCString();
        score =  CCString::createWithFormat("%d", Utility::getPlayerScore(0))->getCString();
        distance =  CCString::createWithFormat("%d meters", Utility::getLongestDistance())->getCString();
        wallsSmashed =  CCString::createWithFormat("%d", Utility::getTotalWallSmashedLifeTime())->getCString();
        tightSqueezes =  CCString::createWithFormat("%d", Utility::getTotalTightSqueezesLifeTime())->getCString();
    }         
        createLabelForStats("score:", score, ccp(winSize.width * 0.55, winSize.height * 0.65), statsLayer);
        createLabelForStats("distance:", distance, ccp(winSize.width * 0.55, winSize.height * 0.55), statsLayer);
        createLabelForStats("walls smashed:", wallsSmashed, ccp(winSize.width * 0.55, winSize.height * 0.45), statsLayer);
        createLabelForStats("tight squeezes:", tightSqueezes, ccp(winSize.width * 0.55, winSize.height * 0.35), statsLayer);
        createLabelForStats("game time:", longestGamePlayed, ccp(winSize.width * 0.55, winSize.height * 0.25), statsLayer);
    
        addChild(statsLayer, 1);
    
}
示例#26
0
 bool ComicScene::init() {
     if ( !CCLayer::init() ) {
         return false;
     }
     this->setIsKeypadEnabled(true);
     CCDirector::sharedDirector()->resume();
     this->touchEnabled=true;
     this->currentPage = 0;
     this->cleanAfterExit = false;
     CCSpriteBatchNode* batch = new CCSpriteBatchNode();
     batch->initWithTexture(CCTextureCache::sharedTextureCache()->textureForKey(Config::sharedConfig()->COMIC_PNG.c_str()), 6);
     this->addChild(batch, 0, BATCH_COMIC_INTRO_TAG);
     CCSprite* gSettingBackground = CCSprite::spriteWithSpriteFrameName(COMIC_INTRO_BG.c_str());
     gSettingBackground->setPosition(Geometry::getScreenCenter());
     this->addChild(gSettingBackground, 0);
     CCLabelBMFont* labelTouch = CCLabelBMFont::labelWithString(Config::sharedConfig()->LANG_CONTINUE.c_str(), Config::sharedConfig()->BMFONT_NAME.c_str());
     labelTouch->setColor(ccc3(50,50,50));
     labelTouch->setScale(0.7);
     labelTouch->setPosition( CCPoint(Geometry::getScreenBotomCenter(24)) );
     this->addChild(labelTouch, 2, 100);
     if(!SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying() && SimpleAudioEngine::sharedEngine()->getBackgroundMusicVolume() > 0) {
         SimpleAudioEngine::sharedEngine()->playBackgroundMusic(CCFileUtils::fullPathFromRelativePath(MUSIC_LEVEL2.c_str()), true);
     }
     CCSprite* sPage1;
     CCSprite* sPage2;
     CCSprite* sPage3;
     CCLabelBMFont* sText1;
     CCLabelBMFont* sText2;
     CCLabelBMFont* sText3;
     if (sequence == 1) {
         sPage1 = CCSprite::spriteWithSpriteFrameName(COMIC_INTRO_1.c_str());
         sPage1->setPosition( CCPoint(Geometry::getScreenBotomCenter(Config::sharedConfig()->COMIC_ADJUST_PAGE_A)) );
         sPage1->setOpacity(0);
         this->addChild(sPage1, 1, 1);
         sText1 = CCLabelBMFont::labelWithString(Config::sharedConfig()->LANG_COMIC_TEXT_1.c_str(), Config::sharedConfig()->BMFONT_NAME.c_str());
         sText1->setColor(ccc3(45,0,0));
         sText1->setPosition( CCPoint(Geometry::getScreenUpCenter(-Config::sharedConfig()->COMIC_ADJUST_TXT_A)) );
         this->addChild(sText1, 1, 2);
         sPage2 = CCSprite::spriteWithSpriteFrameName(COMIC_INTRO_2.c_str());
         sPage2->setPosition( CCPoint(Geometry::getScreenBotomCenter(Config::sharedConfig()->COMIC_ADJUST_PAGE_B)) );
         sPage2->setOpacity(0);
         this->addChild(sPage2, 1, 3);
         sText2 = CCLabelBMFont::labelWithString(Config::sharedConfig()->LANG_COMIC_TEXT_2.c_str(), Config::sharedConfig()->BMFONT_NAME.c_str());
         sText2->setColor(ccc3(45,0,0));
         sText2->setPosition( CCPoint(Geometry::getScreenUpCenterAdjust(-Config::sharedConfig()->SCREEN_WIDTH,Config::sharedConfig()->COMIC_ADJUST_TXT_C)) );
         this->addChild(sText2, 1, 4);
         sPage3 = CCSprite::spriteWithSpriteFrameName(COMIC_INTRO_3.c_str());
         sPage3->setPosition( CCPoint(Geometry::getScreenBotomCenter(Config::sharedConfig()->COMIC_ADJUST_PAGE_C)) );
         sPage3->setOpacity(0);
         this->addChild(sPage3, 1, 5);
         sText3 = CCLabelBMFont::labelWithString(Config::sharedConfig()->LANG_COMIC_TEXT_3.c_str(), Config::sharedConfig()->BMFONT_NAME.c_str());
         sText3->setColor(ccc3(45,0,0));
         sText3->setPosition( CCPoint(Geometry::getScreenUpCenterAdjust(Config::sharedConfig()->SCREEN_WIDTH,Config::sharedConfig()->COMIC_ADJUST_TXT_C)) );
         this->addChild(sText3, 1, 6);
         this->totalPages = 3;
     } else if (sequence == 2) {
         sPage1 = CCSprite::spriteWithSpriteFrameName(COMIC_END_1.c_str());
         sPage1->setPosition( CCPoint(Geometry::getScreenBotomCenter(Config::sharedConfig()->COMIC_ADJUST_PAGE_A)) );
         sPage1->setOpacity(0);
         this->addChild(sPage1, 1, 1);
         sText1 = CCLabelBMFont::labelWithString(Config::sharedConfig()->LANG_COMIC_TEXT_4.c_str(), Config::sharedConfig()->BMFONT_NAME.c_str());
         sText1->setColor(ccc3(45,0,0));
         sText1->setPosition( CCPoint(Geometry::getScreenUpCenterAdjust(-Config::sharedConfig()->SCREEN_WIDTH,Config::sharedConfig()->COMIC_ADJUST_TXT_A)) );
         this->addChild(sText1, 1, 2);
         sPage2 = CCSprite::spriteWithSpriteFrameName(COMIC_END_2.c_str());
         sPage2->setPosition( CCPoint(Geometry::getScreenBotomCenter(Config::sharedConfig()->COMIC_ADJUST_PAGE_E)) );
         sPage2->setOpacity(0);
         this->addChild(sPage2, 1, 3);
         sText2 = CCLabelBMFont::labelWithString(Config::sharedConfig()->LANG_COMIC_TEXT_5.c_str(), Config::sharedConfig()->BMFONT_NAME.c_str());
         sText2->setColor(ccc3(45,0,0));
         sText2->setPosition( CCPoint(Geometry::getScreenUpCenterAdjust(Config::sharedConfig()->SCREEN_WIDTH,Config::sharedConfig()->COMIC_ADJUST_TXT_E)) );
         this->addChild(sText2, 1, 4);
         this->totalPages = 2;
     }
     showCurrentPage();
     CCTouchDispatcher::sharedDispatcher()->addTargetedDelegate(this, 0, true);
     //ipad fix
     if(CCDirector::sharedDirector()->getWinSizeInPixels().width >= 768) {
         Border* border = new Border();
         this->addChild(border, 999);
     }
     return true;
 }
示例#27
0
bool SecondLevel::init()
{
	if (!CCLayer::init())
	{
		return false;
	}

	isRemoved = false;
	isDone = false;
	CCSize winSize = CCDirector::sharedDirector()->getVisibleSize();

	CCSprite *bg = CCSprite::createWithTexture(IMAGEPOOL->textureForKey("/pic/background.png"));
	bg->setPosition(ccp(winSize.width / 2, winSize.height / 2));
	this->addChild(bg, 0);

	rule_img = CCSprite::createWithTexture(IMAGEPOOL->textureForKey("/pic/level2.png"));
	rule_img->setPosition(ccp(winSize.width / 2, winSize.height / 2));
	rule_img->setScale(0.4f);
	rule_img->setTag(10);
	this->addChild(rule_img, 1);

	forward_button = CCSprite::createWithTexture(IMAGEPOOL->textureForKey("/pic/forward.png"));
	forward_button->setPosition(ccp(350,
		forward_button->getContentSize().height / 2 + CCDirector::sharedDirector()->getVisibleOrigin().y));
	rule_img->addChild(forward_button);

	key_img = CCSprite::createWithTexture(IMAGEPOOL->textureForKey("/pic/level2_key_face.png"));
	key_img->setPosition(ccp(winSize.width / 2, winSize.height / 2));
	key_img->setVisible(false);
	this->addChild(key_img, 1);

	candidatite_img = CCSprite::createWithTexture(IMAGEPOOL->textureForKey("/pic/level2_condaditate_faces.png"));
	candidatite_img->setPosition(ccp(winSize.width / 2, winSize.height / 2));
	candidatite_img->setScale(0.5f);
	candidatite_img->setVisible(false);
	this->addChild(candidatite_img, 1);


	result = CCSprite::createWithTexture(IMAGEPOOL->textureForKey("/pic/result.png"));
	result->setPosition(ccp(winSize.width / 2, winSize.height / 2));
	result->setVisible(false);
	this->addChild(result, 1);

	CCSprite *back = CCSprite::createWithTexture(IMAGEPOOL->textureForKey("/pic/back.png"));
	back->setPosition(ccp(60, 100));
	back->setScale(0.7f);
	result->addChild(back);



	CCLabelBMFont *lbLife = CCLabelBMFont::create("20", "/word/font09.fnt");
	lbLife->setAnchorPoint(ccp(0, 1));
	lbLife->setScale(0.6f);
	lbLife->setPosition(ccp(winSize.width - 70, winSize.height - 1));
	lbLife->setVisible(false);
	this->addChild(lbLife, 1, 15);

	this->setTouchEnabled(true);
	this->setTag(0);
	return true;
}
示例#28
0
bool GameLayer::init(void)
{
	bool bRet = false;
	do 
	{
		CC_BREAK_IF(!CCLayer::init());

		// 游戏场景背景图
		CCSprite *bg = CCSprite::spriteWithFile("Space.png");
		CC_BREAK_IF(!bg);
		bg->setAnchorPoint(CCPointZero);
		// 为了突出游戏场景中的精灵,将背景色彩变淡
		bg->setOpacity(100);
		this->addChild(bg, 0, 1);

		// 使用位图字体显示游戏时间
		CCLabelBMFont* lbScore = CCLabelBMFont::labelWithString("Time: 0", "font09.fnt");
		CC_BREAK_IF(!lbScore);
		lbScore->setAnchorPoint(ccp(1, 1));
		lbScore->setScale(0.6f);
		this->addChild(lbScore, 1, 3);
		lbScore->setPosition(ccp(310, 450));

		// 载入飞船图像集
		CCSpriteBatchNode* mgr = CCSpriteBatchNode::batchNodeWithFile("flight.png", 5);
		CC_BREAK_IF(!mgr);
		this->addChild(mgr, 0, 4);

		// 在状态栏显示一个飞船的图标
		CCSprite* sprite = CCSprite::spriteWithTexture(mgr->getTexture(), CCRectMake(0, 0, 31, 30));
		CC_BREAK_IF(!sprite);
		mgr->addChild(sprite, 1, 5);
		sprite->setScale(1.1f);
		sprite->setAnchorPoint(ccp(0, 1));
		sprite->setPosition(ccp(10, 460));

		// 显示当前飞船生命条数
		CCLabelBMFont* lbLife = CCLabelBMFont::labelWithString("3", "font09.fnt");
		CC_BREAK_IF(!lbLife);
		lbLife->setAnchorPoint(ccp(0, 1));
		lbLife->setScale(0.6f);
		this->addChild(lbLife, 1, 6);
		lbLife->setPosition(ccp(50, 450));

		// 设定时间回调函数,修改游戏用时显示
		this->schedule(schedule_selector(GameLayer::step), 1.0f);

		// 显示飞船,飞船有不断闪烁的火焰喷射效果
		flight = CCSprite::spriteWithTexture(mgr->getTexture(), CCRectMake(0, 0, 31, 30));
		CC_BREAK_IF(!flight);
		flight->setPosition(ccp(160, 30));
		flight->setScale(1.6f);
		mgr->addChild(flight, 1, 99);

		// 设定动画每一帧的内容
		CCAnimation* animation = CCAnimation::animation();
		CC_BREAK_IF(!animation);
		animation->setName("flight");
		animation->setDelayPerUnit(0.2f);
		for (int i = 0; i < 3; ++i)
		{
			int x = i % 3;
			animation->addSpriteFrameWithTexture(mgr->getTexture(), CCRectMake(x*32, 0, 31, 30));
		}

		// 基于动画创建动作
		CCAnimate* action = CCAnimate::actionWithAnimation(animation);
		CC_BREAK_IF(!action);

		// 主角精灵不断重复动作,实现动态飞行效果
		flight->runAction(CCRepeatForever::actionWithAction(action));

		// accept touch now
		this->setTouchEnabled(true);

		bRet = true;
	} while (false);

	return bRet;
}