Exemplo n.º 1
0
bool Settings::initWithFile(const char * pszFilename)
{
    Button::initWithFile(pszFilename);
    setScaleWhenTouch(false);

    setName("settings");
    CCSprite * settingsText = CCSprite::create("ui/settings_text.png");
    settingsText->setAnchorPoint(ccp(0.5,1.0));
    settingsText->setPosition(ccp(getContentSize().width/2, getContentSize().height-size(2.5)));
    addChild(settingsText);

    CCLabelBMFont * musicLabel = CCLabelBMFont::create("Background Music", "font/item_count.fnt");
    musicLabel->setAnchorPoint(ccp(0.5, 0.0));
    musicLabel->setPosition(ccp(center(this).x, size(345)));
    addChild(musicLabel);

    m_buttonBGMOn = new Button;
    m_buttonBGMOn->initWithFile("ui/settings_on.png");
    m_buttonBGMOn->setAnchorPoint(ccp(1.0, 0.0));
    m_buttonBGMOn->setPosition(ccp(center(this).x-size(10), size(280)));
    m_buttonBGMOn->setActID(BUTTON_BGM_ON);
    addChild(m_buttonBGMOn);
    addButton(m_buttonBGMOn);

    m_buttonBGMOff = new Button;
    m_buttonBGMOff->initWithFile("ui/settings_off.png");
    m_buttonBGMOff->setAnchorPoint(ccp(0.0, 0.0));
    m_buttonBGMOff->setPosition(ccp(center(this).x+size(10), size(280)));
    m_buttonBGMOff->setActID(BUTTON_BGM_OFF);
    addChild(m_buttonBGMOff);
    addButton(m_buttonBGMOff);

    CCLabelBMFont * msgLabel = CCLabelBMFont::create("Notifications", "font/item_count.fnt");
    msgLabel->setAnchorPoint(ccp(0.5, 0.0));
    msgLabel->setPosition(ccp(center(this).x, size(210)));
    addChild(msgLabel);

    m_buttonMsgOn = new Button;
    m_buttonMsgOn->initWithFile("ui/settings_on.png");
    m_buttonMsgOn->setAnchorPoint(ccp(1.0, 0.0));
    m_buttonMsgOn->setPosition(ccp(center(this).x-size(10), size(145)));
    m_buttonMsgOn->setActID(BUTTON_MSG_ON);
    addChild(m_buttonMsgOn);
    addButton(m_buttonMsgOn);

    m_buttonMsgOff = new Button;
    m_buttonMsgOff->initWithFile("ui/settings_off.png");
    m_buttonMsgOff->setAnchorPoint(ccp(0.0, 0.0));
    m_buttonMsgOff->setPosition(ccp(center(this).x+size(10), size(145)));
    m_buttonMsgOff->setActID(BUTTON_MSG_OFF);
    addChild(m_buttonMsgOff);
    addButton(m_buttonMsgOff);

    update();

    return true;
}
Exemplo n.º 2
0
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);
}
Exemplo n.º 3
0
//定时执行分数自动增减
void CFScoreBoard::doAutoScore(ccTime dt){
    if(scorePerSec == 0 && ((int)dt%60)!=0){
        return;
    }
    this->score+=scorePerSec;
    int num = cun(score);
    for(int i = 0; i < num;i++){
        int slot = pow(10.0,i);
        int digital = (score/slot)%10;
        char* buffer = new char[5];
        sprintf(buffer, "%d", digital);
        CCLabelBMFont* pLabel =(CCLabelBMFont*) this->getChildByTag(i);
        if(!pLabel){
            pLabel =  CCLabelBMFont::labelWithString(buffer,"fonts/fonts.fnt");
            CCSize labelsize = pLabel->getContentSize();
            pLabel->setPosition(ccp(width-i*20,height/2));
            pLabel->setTag(i);
            this->addChild(pLabel);
        }else{
            pLabel->setString(buffer);
        }
        this->doChangeAnimation(scorePerSec);
        delete[] buffer;
    }
}
Exemplo n.º 4
0
void NewChapterOpen::initContent()
{
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/fightUI/newChapter.plist");
    
    CCSprite *sp_bg = CCSprite::createWithSpriteFrameName("newChapter_bg.png");
    CCString *miniMapStr = CCString::createWithFormat("ui/chapter/miniMaps/mini_%d.png",sceneId);
    CCSprite *miniMap = CCSprite::create(miniMapStr->getCString());
    sp_bg->addChild(miniMap);
    miniMap->setPosition(getCenterPosition(sp_bg));
    
    CCSprite* sp_2 = CCSprite::createWithSpriteFrameName("newChapter_other.png");
    sp_bg->addChild(sp_2);
    sp_2->setPosition(ccp(sp_bg->getContentSize().width,sp_bg->getContentSize().height/2));

    CCLabelBMFont *label = CCLabelBMFont::create("恭喜开启新关卡", "font/font_ui.fnt");
    sp_bg->addChild(label);
    label->setPosition(ccp(sp_bg->getContentSize().width/2, sp_bg->getContentSize().height));
    
    CCScrollView* view = CCScrollView::create();
    view->setContainer(sp_bg);
    view->setTouchEnabled(false);
    view->setContentOffset(ccp(-425, 20));
    view->setViewSize(CCSizeMake(537, 370));
    view->setContentSize(view->getViewSize());
    view->setPosition(ccp(-view->getContentSize().width/2 + 40, -view->getContentSize().height/2));
    addChild(view);
    
    CCSprite *sp_1 = CCSprite::createWithSpriteFrameName("newChapter_other.png");
    addChild(sp_1);
    sp_1->setPosition(ccp(-225, 2));
    
    view->setContentOffsetInDuration(ccp(0, 20), 0.2);
}
Exemplo n.º 5
0
void DifficultyLayer::onEnter()
{
	CCLayer::onEnter();

	//create title
	CCLabelBMFont *pLabelTitle = CCLabelBMFont::labelWithString("游戏模式选择", rcImageFont40);
	pLabelTitle->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y*(1.0f/4.0f)));
	this->addChild(pLabelTitle,1);

	//create menu item
	CCMenuItemImage *pEasyItem = CCMenuItemImage::create(rcDifficultyItemEasyNormal, rcDifficultyItemEasySelected, this, menu_selector(DifficultyLayer::EasyCallback));
	CCMenuItemImage *pNormalItem = CCMenuItemImage::create(rcDifficultyItemNormalNormal, rcDifficultyItemNormalSelected, this, menu_selector(DifficultyLayer::NormalCallback)); 
	CCMenuItemImage *pHardItem = CCMenuItemImage::create(rcDifficultyItemHardNormal, rcDifficultyItemHardSelected, this, menu_selector(DifficultyLayer::HardCallback)); 

	pEasyItem->setPosition(ccp(VisibleRect::right().x*(1.0/5.0),VisibleRect::center().y));
	pNormalItem->setPosition(ccp(VisibleRect::right().x*(1.0f/4.0f),VisibleRect::center().y));
	pHardItem->setPosition(ccp(VisibleRect::right().x*(3.0f/4.0f),VisibleRect::center().y));

	CCMenu* pMenu = CCMenu::create(/*pEasyItem, */pNormalItem, pHardItem, NULL);
	pMenu->setPosition(CCPointZero);

	this->addChild(pMenu, 1);
	//end create menu item

	// BackGround
		CCSprite* pSprite = CCSprite::create(rcDifficultyBackGround);
		if(pSprite){
			// Place the sprite on the center of the screen
			//pSprite->setAnchorPoint(ccp(0,0));
			pSprite->setPosition(VisibleRect::center());

			// Add the sprite to layer as a child layer.
			this->addChild(pSprite, 0);
		}
}
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;
}
CCMenuItemSprite * CCMenuItemDynamic::dynamicItemWithText(const char* text,  const char* font, const CCSize &minSize,  const char*normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector, const CCRect& centerRegion, GLubyte opacity) {
	  //Create the label
	  CCLabelBMFont *label = CCLabelBMFont ::labelWithString(text ,font);
	  label ->setOpacity(opacity);

	  //Calculate the Dynamic Button size
	  float minWidth = label->getContentSize().width>minSize.width?label->getContentSize().width:minSize.width;
	  float minHeight = label->getContentSize().height>minSize.height?label->getContentSize().height:minSize.height;

	  CCSize size(minWidth+30,minHeight+24);

	  label->setPosition(ccp(size.width*0.5f, size.height*0.5f));

	  //Sprite normal
	  CCScale9Sprite *normalSprite = CCScale9Sprite::scale9SpriteWithFile(normalImage, centerRegion);	
	  normalSprite ->setContentSize(size);
	  normalSprite ->setOpacity(opacity);
	  //Sprite selected
	  CCScale9Sprite *selectedSprite = NULL;
	  if(selectedImage){
		  selectedSprite = CCScale9Sprite::scale9SpriteWithFile(selectedImage, centerRegion);	
		  selectedSprite ->setContentSize(size);
		  selectedSprite->setOpacity(opacity);
	  }

	  //Create the CCMenuItemSprite
	  CCMenuItemSprite* returnItem = CCMenuItemSprite::itemFromNormalSprite(normalSprite,selectedSprite,target, selector);
	  returnItem->addChild(label);
	  return returnItem;

}
Exemplo n.º 8
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 );
    
}
Exemplo n.º 9
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;
}
void GuessSpellItem::showGift()
{
    m_showNode = CCNode::create();
    std::string imgName;
    PropDef::getVirtualPropsName(m_giftType,imgName);
    imgName += ".png";
    CCSprite *giftSprite = CCSprite::createWithSpriteFrameName(imgName.data());
    std::stringstream ss;
    ss << "x" << m_giftCount;
    CCLabelBMFont *giftNum = CCLabelBMFont::create(ss.str().data(),"fonts/font20.fnt");
    CCSize giftSize = giftSprite->getContentSize();
    CCSize numSize = giftNum->getContentSize();
    CCSize size = CCSizeMake(MAX(giftSize.width,numSize.width),giftSize.height + numSize.height);
    m_showNode->setContentSize(size);
    m_showNode->addChild(giftSprite);
    m_showNode->addChild(giftNum);
    giftSprite->setAnchorPoint(ccp(0,1.0));
    giftSprite->setPosition(ccp(0,size.height));
    giftNum->setAnchorPoint(ccp(0.5,0));
    giftNum->setPosition(ccp(size.width/2,0));
    this->CCNode::addChild(m_showNode,100);
    m_showNode->setAnchorPoint(ccp(0.5,0.5));
    m_showNode->setPosition(ccp(m_anchorWidth/2,m_anchorHeight/2));
    m_showNode->setVisible(true);
    m_showNode->runAction(CCSequence::create(CCScaleTo::create(0.5,10),
                          CCCallFuncN::create(this,callfuncN_selector(GuessSpellItem::onShowGiftFinished)),0));
}
Exemplo n.º 11
0
LabelBMFontChinese::LabelBMFontChinese()
{
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    CCLabelBMFont* pLable = CCLabelBMFont::create("中国", "fonts/bitmapFontChinese.fnt");
    pLable->setPosition(ccp(size.width / 2, size.height /2));
    this->addChild(pLable);
}
Exemplo n.º 12
0
LabelBMFontChinese::LabelBMFontChinese()
{
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    CCLabelBMFont* pLable = CCLabelBMFont::labelWithString("abc中国中国efghi中国中国JKLMn中国", "fonts/bitmapFontChinese.fnt", CCTextAlignmentRight, 300);
    pLable->setLineBreakWithoutSpace(true);
	pLable->setPosition(ccp(size.width / 2, size.height /2));
    this->addChild(pLable);
}
Exemplo n.º 13
0
//bit map font 
CCLabelBMFont* VGPLabel::createLabelBMFont( char *strName, char* fntFile, float width, cocos2d::CCPoint position, CCTextAlignment alignment, CCPoint imageOffset, int zOrder, int tag )
{
	CCLabelBMFont *label = CCLabelBMFont::create( strName, fntFile, width, alignment, imageOffset);
	label->setPosition( position ); 
	label->setZOrder( zOrder );
	label->setTag( tag );
	return label;
}
Exemplo n.º 14
0
// Initialize the GameScene
bool GameScene::init()
{
	CCLog("GameScene::init");
    bool bRet = false;
    do 
    {
        //////////////////////////////////////////////////////////////////////////
        // super init first
        //////////////////////////////////////////////////////////////////////////
        CC_BREAK_IF(! CCLayer::init());

		// Initialize the parent - gets the sprite sheet loaded, sets the background and inits the clouds
		MainScene::init();

		// Start off as game suspended
		gameSuspended = true;

		// Get the bird sprite
		CCSprite *bird = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bird.png"));
		this->addChild(bird, 4, kBird);

		// Initialize the platforms
		initPlatforms();

		// Create the bonus sprite
		CCSprite *bonus;

		// Load in the bonus images, 5, 10, 50, 100
		for(int i=0; i<kNumBonuses; i++) 
		{
			bonus = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(bonus_image[i]));
			this->addChild(bonus,4, kBonusStartTag+i);
			bonus->setVisible(false);
		}

		// Create the Score Label
		CCLabelBMFont* scoreLabel = CCLabelBMFont::create("0",  "Images/bitmapFont.fnt");
		this->addChild(scoreLabel, 5, kScoreLabel);

		// Center the label
		scoreLabel->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width/2,CCDirector::sharedDirector()->getWinSize().height - 50));

		// Start the GameScene stepping
		schedule(schedule_selector(GameScene::step));

		// Enable the touch events
		setTouchEnabled(true);
		// Enable accelerometer events
		setAccelerometerEnabled(true);

		// Start the game
		startGame();

        bRet = true;
    } while (0);

    return bRet;
}
Exemplo n.º 15
0
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);
}
Exemplo n.º 17
0
void GameScene::showStartLabel() {
	CCLabelBMFont* startLabel = CCLabelBMFont::create("Touch to Start",
			FONT_TOUCH);
	startLabel->setPosition(
			ccp(g_visibleSize.width * 0.5, g_visibleSize.height * 0.5));
	startLabel->setTag(kTagStartLabel);
	this->addChild(startLabel);
	startLabel->runAction(Animations::topLabelAction());
}
Exemplo n.º 18
0
Atlas5::Atlas5()
{
	CCLabelBMFont *label = CCLabelBMFont::labelWithString("abcdefg", "fonts/bitmapFontTest4.fnt");
	addChild(label);
	
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	
	label->setPosition( ccp(s.width/2, s.height/2) );
	label->setAnchorPoint( ccp(0.5f, 0.5f) );
}
Exemplo n.º 19
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;
}
Exemplo n.º 20
0
Atlas6::Atlas6()
{
	CCSize s = CCDirector::sharedDirector()->getWinSize();

	CCLabelBMFont* label = NULL;
	label = CCLabelBMFont::labelWithString("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt");
	addChild(label);
	label->setPosition( ccp(s.width/2, s.height/2+50) );
	label->setAnchorPoint( ccp(0.5f, 0.5f) ) ;
	
	label = CCLabelBMFont::labelWithString("fafefifofu", "fonts/bitmapFontTest5.fnt");
	addChild(label);
	label->setPosition( ccp(s.width/2, s.height/2) );
	label->setAnchorPoint( ccp(0.5f, 0.5f) );

	label = CCLabelBMFont::labelWithString("aeiou", "fonts/bitmapFontTest5.fnt");
	addChild(label);
	label->setPosition( ccp(s.width/2, s.height/2-50) );
	label->setAnchorPoint( ccp(0.5f, 0.5f) ); 
}
Exemplo n.º 21
0
void GridLayer::InitScaleLabel()
{
   CCSize scrSize = CCDirector::sharedDirector()->getWinSize();
   char buffer[32];
   
   sprintf(buffer,"Scale\n%4.2f",Viewport::Instance().GetScale());
   
   CCLabelBMFont* label = CCLabelBMFont::create(buffer, "Arial_32_Green.fnt",100,kCCTextAlignmentCenter);
   label->setPosition(ccp(0.95f*scrSize.width,0.95f*scrSize.height));
   label->setTag(TAG_LABEL_SCALE);
   addChild(label);
}
Exemplo n.º 22
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);

}
bool LevelCompleteLayer::init()
{
	bool pRet = false;
	if (CCLayer::init())
	{
		// Accept touch input
		this->setIsTouchEnabled(true);

		hasBeenSkipped = false;

		// If Viking is dead, reset him and show the tombstone,
		// Any touch gets you back to the main menu
		bool didPlayerDie = GameManager::sharedGameManager()->getHasPlayerDied();
		CCSprite *background = NULL;
		if (didPlayerDie) {
			background = CCSprite::spriteWithFile("Menus/LevelComplete/LevelCompleteDead.png");
		} else {
			background = CCSprite::spriteWithFile("Menus/LevelComplete/LevelCompleteAlive.png");
		}

		background->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
		this->addChild(background);

		// Add the text for level complete.
		CCLabelBMFont *levelLabelText = CCLabelBMFont::labelWithString("Level Complete", "Fonts/VikingSpeechFont64.fnt");
		levelLabelText->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT * 0.9f));
		this->addChild(levelLabelText);

		char killNumber[100] = {0};
		sprintf(killNumber, "Kill Count: %d", GameManager::sharedGameManager()->getKillCount());
		CCLabelBMFont *killCountText = CCLabelBMFont::labelWithString(killNumber, "Fonts/VikingSpeechFont64.fnt");
		killCountText->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT * 0.6f));
		this->addChild(killCountText);
		GameManager::sharedGameManager()->setKillCount(0);
		pRet = true;
	}

	return pRet;
}
Exemplo n.º 24
0
Atlas6::Atlas6()
{
	CCSize s = CCDirector::sharedDirector()->getWinSize();

	CCLabelBMFont* label = NULL;
	//中国
	label = CCLabelBMFont::labelWithString("中国", "fonts/bitmapFontChinese.fnt", 
		CCTextAlignmentRight, 200);
	addChild(label);
	label->setPosition( ccp(s.width / 2.0f, s.height / 2.0f + 50) );
	label->setAnchorPoint( ccp(1.0f, 0.5f) ) ;
	
	label = CCLabelBMFont::labelWithString("fafefifofu", "fonts/bitmapFontTest5.fnt");
	addChild(label);
	label->setPosition( ccp(s.width/2, s.height/2) );
	label->setAnchorPoint( ccp(0.5f, 0.5f) );

	label = CCLabelBMFont::labelWithString("aeiou", "fonts/bitmapFontTest5.fnt");
	addChild(label);
	label->setPosition( ccp(s.width/2, s.height/2-50) );
	label->setAnchorPoint( ccp(0.5f, 0.5f) ); 
}
Exemplo n.º 25
0
BMFontInit::BMFontInit()
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCLabelBMFont* bmFont = new CCLabelBMFont();
    bmFont->init();
    bmFont->autorelease();
    //CCLabelBMFont* bmFont = [CCLabelBMFont create:@"Foo" fntFile:@"arial-unicode-26.fnt"];
    bmFont->setFntFile("fonts/helvetica-32.fnt");
    bmFont->setString("It is working!");
    this->addChild(bmFont);
    bmFont->setPosition(ccp(s.width/2,s.height/4*2));
}
Exemplo n.º 26
0
//------------------------------------------------------------------
//
// Atlas4
//
//------------------------------------------------------------------
Atlas4::Atlas4()
{
	m_time = 0;

	// Upper Label
	CCLabelBMFont *label = CCLabelBMFont::labelWithString("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt");
	addChild(label);
	
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	
	label->setPosition( ccp(s.width/2, s.height/2) );
	label->setAnchorPoint( ccp(0.5f, 0.5f) );
	
	
	CCSprite* BChar = (CCSprite*) label->getChildByTag(0);
	CCSprite* FChar = (CCSprite*) label->getChildByTag(7);
	CCSprite* AChar = (CCSprite*) label->getChildByTag(12);
	
	
	CCActionInterval* rotate = CCRotateBy::actionWithDuration(2, 360);
	CCAction* rot_4ever = CCRepeatForever::actionWithAction(rotate);
	
	CCActionInterval* scale = CCScaleBy::actionWithDuration(2, 1.5f);
	CCActionInterval* scale_back = scale->reverse();
	CCFiniteTimeAction* scale_seq = CCSequence::actions(scale, scale_back,NULL);
	CCAction* scale_4ever = CCRepeatForever::actionWithAction((CCActionInterval*)scale_seq);
	
	CCActionInterval* jump = CCJumpBy::actionWithDuration(0.5f, CCPointZero, 60, 1);
	CCAction* jump_4ever = CCRepeatForever::actionWithAction(jump);
	
	CCActionInterval* fade_out = CCFadeOut::actionWithDuration(1);
	CCActionInterval* fade_in = CCFadeIn::actionWithDuration(1);
	CCFiniteTimeAction* seq = CCSequence::actions(fade_out, fade_in, NULL);
	CCAction* fade_4ever = CCRepeatForever::actionWithAction((CCActionInterval*)seq);
	
	BChar->runAction(rot_4ever);
	BChar->runAction(scale_4ever);
	FChar->runAction(jump_4ever);
	AChar->runAction(fade_4ever);
	
	
	// Bottom Label
	CCLabelBMFont *label2 = CCLabelBMFont::labelWithString("00.0", "fonts/bitmapFontTest.fnt");
	addChild(label2, 0, kTagBitmapAtlas2);
	label2->setPosition( ccp(s.width/2.0f, 80) );
	
	CCSprite* lastChar = (CCSprite*) label2->getChildByTag(3);
	lastChar->runAction( (CCAction*)(rot_4ever->copy()->autorelease()) );
	
	schedule( schedule_selector(Atlas4::step), 0.1f);
}
Exemplo n.º 27
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));
}
Exemplo n.º 28
0
AtlasBitmapColor::AtlasBitmapColor()
{
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	
	CCLabelBMFont* label = NULL;
	label = CCLabelBMFont::labelWithString("Blue", "fonts/bitmapFontTest5.fnt");
	label->setColor( ccBLUE );
	addChild(label);
	label->setPosition( ccp(s.width/2, s.height/4) );
	label->setAnchorPoint( ccp(0.5f, 0.5f) );

	label = CCLabelBMFont::labelWithString("Red", "fonts/bitmapFontTest5.fnt");
	addChild(label);
	label->setPosition( ccp(s.width/2, 2*s.height/4) );
	label->setAnchorPoint( ccp(0.5f, 0.5f) );
	label->setColor( ccRED );

	label = CCLabelBMFont::labelWithString("G", "fonts/bitmapFontTest5.fnt");
	addChild(label);
	label->setPosition( ccp(s.width/2, 3*s.height/4) );
	label->setAnchorPoint( ccp(0.5f, 0.5f) );
	label->setColor( ccGREEN );
	label->setString("Green");
}
Exemplo n.º 29
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);
	
}
Exemplo n.º 30
0
//执行去除老数字的动画
void CFScoreBoard::doChangeAnimation(int change){
    char* buffer = new char[5];
    sprintf(buffer, "%d", change);
    CCLabelBMFont* pLabel =  CCLabelBMFont::labelWithString(buffer,"fonts/fonts.fnt");
    CCSize size = this->getContentSize();
    CCPoint lpos = ccp(size.width/2, size.height/2);
    pLabel->setPosition(lpos);
    this->addChild(pLabel);
    CCMoveTo* pMove = CCMoveTo::actionWithDuration(0.5, ccp(lpos.x, lpos.y-100));
    CCFadeTo* pFade = CCFadeTo::actionWithDuration(0.5, 0);
    CCFiniteTimeAction* pMoveFade = CCSpawn::actions(pMove, pFade,NULL);
    CCDelayTime* pDelay = CCDelayTime::actionWithDuration(0.5);
    CCCallFunc* pFunc = CCCallFuncN::actionWithTarget(this,callfuncN_selector(CFScoreBoard::freeLabel));
    CCAction* pSeq = CCSequence::actions(pMoveFade, pDelay, pFunc,NULL);
    pLabel->runAction(pSeq);
}