Beispiel #1
0
bool T05CCLabelTTf::init()
{
	if (!BaseLayer::init())
		return false;

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

	/*
		提供了三个类来显示文字
		CCLabelTTf,CCLabelAtlas,CCLabelIBMFont
	*/
	CCLabelTTF* pLabelTTf = CCLabelTTF::create("Hello,World", "Arial", 30);
	addChild(pLabelTTf);
	pLabelTTf->setPosition(ccp(winSize.width / 2, winSize.height / 2));

	setTouchEnabled(true);
	setTouchMode(kCCTouchesOneByOne);

	return true;
}
Beispiel #2
0
bool Recipe15::init()
{
    if ( !RecipeBase::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    
    int fontSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize().height/320.0f * 16;
    std::string text = "CCCallFuncを使用して呼び出されたメソッドにより、\nログ出力されます。";
    CCLabelTTF *label = CCLabelTTF::create(text.c_str(), "Helvetica", fontSize);
    label->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
    this->addChild(label);
    
    CCLog("--- Recipe 15 ------");
    this->method1();
    
    return true;
}
bool TitleNode::init() {
    if( !iNode::init() )
        return false;
    
    CCSize designResoulutionSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize();
    
    CCSize labelDimension = CCSizeMake(300, 200);
    CCLabelTTF* sceneDebugLabel = CCLabelTTF::create("Let's\nThree Match!", "Arial", 30, labelDimension, kCCTextAlignmentCenter);
    sceneDebugLabel->setAnchorPoint(ccp(0.5f, 1));
    sceneDebugLabel->setPosition(ccp(designResoulutionSize.width/2, designResoulutionSize.height/2+100));
    sceneDebugLabel->setColor(ccRED);
    this->addChild(sceneDebugLabel);
    
    ProgressControl* progress = ProgressControl::create("UI/gauge_bg.png", "UI/gauge_content.png", NULL, this, callfuncO_selector(TitleNode::onProgressEnded), CommonEnum::eProgressToRight);
    progress->setPosition(ccp((designResoulutionSize.width-progress->boundingBox().size.width)/2, 100));
    progress->setValue(1.0f);
    this->addChild(progress);
    
    return true;
}
Beispiel #4
0
void GameScene::showGametimeLabel()
{
    const int tagGametimeLabel = 100;
    
    CCString* timeString = CCString::createWithFormat("%8.1fs", gametime);
    
    CCLabelTTF* timerLabel = (CCLabelTTF*)this->getChildByTag(tagGametimeLabel);
    if (timerLabel) {
        timerLabel->setString(timeString->getCString());
    }
    else
    {
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        
        timerLabel = CCLabelTTF::create(timeString->getCString(), "Arial", 24.0);
        timerLabel->setPosition(ccp(winSize.width*0.9, winSize.height*0.9));
        timerLabel->setTag(tagGametimeLabel);
        this->addChild(timerLabel);
    }
}
bool HelloWorld::ccTouchBegan(CCTouch *touch, CCEvent *event)
{
    CCPoint touchLocation = touch->getLocation();
    
    char posString [50];
    sprintf (posString, "%0.1f - %0.1f", touchLocation.x, touchLocation.y);
    CCLabelTTF *label = (CCLabelTTF *)this->getChildByTag(999);
    label->setPosition(touchLocation);
    
    if (GeometryUtil::pointInRegion(touchLocation, region)) {
        label->setColor(ccGREEN);
    }
    else {
        label->setColor(ccRED);
    }
    
    label->setString(posString);
    
	return true;
}
// on "init" you need to initialize your instance
bool HelloWorld::init() {
  if (!CCLayer::init()) {
    return false;
  }

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

  CCLabelTTF* pLabel = CCLabelTTF::create("Hello cocos2d-x!", "Thonburi", 48);
  pLabel->setPosition(ccp(windowSize.width / 2, windowSize.height - 36));
  this->addChild(pLabel);

  CCSprite *spaceCargoShip = CCSprite::create("SpaceCargoShip.png");
  spaceCargoShip->setPosition(ccp(windowSize.width/2, windowSize.height/2));
  this->addChild(spaceCargoShip);

  CCMoveTo *movement = CCMoveTo::create(5.0, ccp(0, windowSize.height/2));
  spaceCargoShip->runAction(movement);
  
  return true;
}
void TouchesMainScene::onEnter()
{
    PerformBasicLayer::onEnter();

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

    // add title
    CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 32);
    addChild(label, 1);
    label->setPosition(ccp(s.width/2, s.height-50));

    scheduleUpdate();

    m_plabel = CCLabelBMFont::create("00.0", "fonts/arial16.fnt");
    m_plabel->setPosition(ccp(s.width/2, s.height/2));
    addChild(m_plabel);

    elapsedTime = 0;
    numberOfTouchesB = numberOfTouchesM = numberOfTouchesE = numberOfTouchesC = 0;    
}
Beispiel #8
0
void MainGameScene::showStartInfo()
{
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    CCMenuItemImage* pStartItem;
    pStartItem = CCMenuItemImage::create("logo_Info2.png", "logo_Info2.png",this,menu_selector(MainGameScene::startGame));
    pStartItem->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
    pStartItem->setScale(0.7);
     CCSize pStartItemSize = pStartItem->getContentSize();
    
    CCLabelTTF* startLabel1;
    startLabel1 = CCLabelTTF::create("Let's Arrows", "Copperplate", 60.0);
    startLabel1->setColor(ccc3(0, 0, 0));
    startLabel1->setPosition(ccp(pStartItemSize.width * 0.5 ,pStartItemSize.height * 0.7));
    pStartItem->addChild(startLabel1);
    
    CCString* levelStr = CCString::createWithFormat("Lv:%d",m_level);
    CCLabelTTF* levelLabel;
    levelLabel = CCLabelTTF::create(levelStr->getCString(), "Copperplate", 60.0);
    levelLabel->setColor(ccc3(0, 0, 0));
    levelLabel->setPosition(ccp(pStartItemSize.width * 0.5 ,pStartItemSize.height * 0.5));
    pStartItem->addChild(levelLabel);


    
    CCString* minCountString = CCString::createWithFormat("MIN  %d  TOUCH",minimamCount);
    CCLabelTTF* startLabel2;
    startLabel2 = CCLabelTTF::create(minCountString->getCString(), "Copperplate", 50.0);
    startLabel2->setColor(ccc3(0, 0, 0));
    startLabel2->setPosition(ccp(pStartItemSize.width * 0.5 ,pStartItemSize.height * 0.2));
    pStartItem->addChild(startLabel2);
    
    
    CCMenu* pMenu = CCMenu::create(pStartItem,NULL);
    pMenu->setPosition(CCPointZero);
    pMenu->setTag(tagStartInfo);
    
    this->addChild(pMenu);

    
}
bool TitleLayer::init()
{
	if ( !CCLayer::init() )
	{
		return false;
	}
    
    // Get window size
    CCSize windowSize = CCDirector::sharedDirector()->getWinSize();
    
    // Create text label for title of game - "@stroids" - don't sue me Atari!
    CCLabelTTF *title = CCLabelTTF::labelWithString("@stroids", "Courier", 64.0);
    
    // Position title at center of screen
    title->setPosition(ccp(windowSize.width / 2, windowSize.height/2));
    
    // Add to layer
    this->addChild(title, 1);
    
    // Set the default CCMenuItemFont font
    CCMenuItemFont::setFontName("Courier");
    
    // Create "play," "scores," and "controls" buttons - when tapped, they call methods we define: playButtonAction and scoresButtonAction
    CCMenuItemFont *playButton = CCMenuItemFont::itemFromString("play", this, menu_selector(TitleLayer::playButtonAction));
    CCMenuItemFont *scoresButton = CCMenuItemFont::itemFromString("scores", this, menu_selector(TitleLayer::scoresButtonAction));
    CCMenuItemFont *controlsButton = CCMenuItemFont::itemFromString("controls", this, menu_selector(TitleLayer::controlsButtonAction));
    
    // Create menu that contains our buttons
    CCMenu *menu = CCMenu::menuWithItems(playButton, scoresButton, controlsButton, NULL);

    // Align buttons horizontally
    menu->alignItemsHorizontallyWithPadding(20);
    
    // Set position of menu to be below the title text
    menu->setPosition(ccp(windowSize.width / 2, title->getPosition().y - title->getContentSize().height / 1.5));

    // Add menu to layer
    this->addChild(menu, 2);
        
	return true;
}
BaseLayer* MainLayerZhuangBeiBody::createContentAtIndex(unsigned int index)
{
	MainLayerZhuangBeiBaseBody* ret = NULL;
	if (index >= sizeof(itemFiles)/sizeof(string))
	{
		//CCLog("MainLayerZhuangBeiBody::createContentAtIndex --> index >= [%d] (sizeof(itemFiles)/sizeof(string))",sizeof(itemFiles)/sizeof(string));
		return ret;
	}
	switch (index)
	{
	case 0://
		ret = new MainLayerZhuangBeiAllBody(Type_WuQi);
		ret->autorelease();
		break;
	case 1://
		ret = new MainLayerZhuangBeiAllBody(Type_FangJu);
		ret->autorelease();
		break;
	case 2://
		ret = new MainLayerZhuangBeiAllBody(Type_ShiPin);
		ret->autorelease();
		break;
	case 3://全部
		ret = new MainLayerZhuangBeiAllBody(Type_All);
		ret->autorelease();
		break;
	default:
		ret = new MainLayerZhuangBeiBaseBody(From_ZhuangBeiList);
		ret->autorelease();

		CCLabelTTF *label = CCLabelTTF::create("Zhuang Bei Not implement!", "Helvetica", 40.0);
		label->setPosition(ccp(mWinSize.width/2,mWinSize.height/2));
		ret->addChild(label);
		break;
	}

	ret->setFooter(mFooterLayer);
	ret->setTableViewPos(ccp(8,74));

	return ret;
}
Beispiel #11
0
void Ajustes::initBtCreditos(){
    btCreditos = MenuItemImage::create("ajustes_btCreditos.png", "ajustes_btCreditos_down.png", callfunc_selector(Ajustes::irCreditos));
    btCreditos->setScale(escalaAncha);
    btCreditos->setAnchorPoint(Vec2(0,0));
    btCreditos->setPosition(espacioSuperiorBtAtras*escala,visibleSize.height/2);
    
    menuCreditos = Menu::create(btCreditos, NULL);
    menuCreditos->setPosition(Vec2::ZERO);
    botonAtras->setZOrder(10);
    menuCreditos->retain();
    this->addChild(menuCreditos, 1);
    
    //btCreditosTexto
    CCLabelTTF *lbBtCreditos = CCLabelTTF::create(LanguageManager::getInstance()->getString("AjustesBtCreditos"), "HVD_Comic_Serif_Pro.ttf", 70,Size(btCreditos->getContentSize().width, 120), TextHAlignment::CENTER);
    lbBtCreditos->setColor(Color3B(255,255,255));
    lbBtCreditos->setVerticalAlignment(TextVAlignment::CENTER);
    lbBtCreditos->setAnchorPoint(Vec2(0.5,0));
    lbBtCreditos->setPosition(btCreditos->getContentSize().width/2,0);
    btCreditos->addChild(lbBtCreditos, 1);
    
}
bool WinScene::init() {
	bool bRet = false;

	do {
		CC_BREAK_IF(! CCLayer::init());

		CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();

		/* 添加一个标签 */
		CCLabelTTF* winLab = CCLabelTTF::create("You Win!", PATH_FONT_PUBLIC, GlobalParam::PublicFontSizeLarge);
		winLab->setPosition(ccp(visibleSize.width / 2, visibleSize.height - 100));
		this->addChild(winLab);

		/* 3秒后返回关卡选择场景 */
		this->schedule(schedule_selector(WinScene::backToTollgateSelectScene), 3.0f);

		bRet = true;
	} while (0);

	return bRet;
}
HelloWorld::HelloWorld()
{
   setTouchEnabled( true );
   setAccelerometerEnabled( true );
   
   CCSize s = CCDirector::sharedDirector()->getWinSize();
   // init physics
   this->initPhysics();
   
   CCSpriteBatchNode *parent = CCSpriteBatchNode::create("blocks.png", 100);
   m_pSpriteTexture = parent->getTexture();
   
   addChild(parent, 0, kTagParentNode);
   
   CCLabelTTF *label = CCLabelTTF::create("Tap screen", "Marker Felt", 32);
   addChild(label, 0);
   label->setColor(ccc3(0,0,255));
   label->setPosition(ccp( s.width/2, s.height-50));
   
   scheduleUpdate();
}
bool RobotLooseLayer::init()
{
    CCSize mapSize = GameParams::getInstanse()->mapSize();
    
    if ( !initWithColor(ccc4(145,145,145,255 * 0.45f)) )
    {
        return false;
    }
    
    CCLabelTTF *label = CCLabelTTF::create(CCLocalizedString("RobotBroken", "NotLocalized"), "Marker Felt", 42);
    
    label->setAnchorPoint( CCPointZero );
    label->setPosition( CCPointZero );
    
    addChild(label, 20);
    
    setContentSize(CCSizeMake(label->getContentSize().width, label->getContentSize().height));
    setPosition(ccp(mapSize.width / 2 - getContentSize().width / 2, -getContentSize().height));
    
    return true;
}
CCTableViewCell* EXMainMenuScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCString *string = (CCString*)m_listData->objectAtIndex(idx);
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell) {
        cell = new CCTableViewCell();
        cell->autorelease();
        CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", 20.0);
        label->setPosition(ccp(m_winSize.width * .5, 30));
        label->setTag(123);
        cell->addChild(label);
    }
    else
    {
        CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
        label->setString(string->getCString());
    }
    
    
    return cell;
}
Beispiel #16
0
RemoveMenuItemWhenMove::RemoveMenuItemWhenMove()
{
    CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    CCLabelTTF* label = CCLabelTTF::create("click item and move, should not crash", "Arial", 20);
    label->setPosition(ccp(s.width/2, s.height - 30));
    addChild(label);
    
    item = CCMenuItemFont::create("item 1");
    item->retain();
    
    CCMenuItemFont *back = CCMenuItemFont::create("go back", this, menu_selector(RemoveMenuItemWhenMove::goBack));
    
    CCMenu *menu = CCMenu::create(item, back, NULL);
    addChild(menu);
    menu->alignItemsVertically();
    
    menu->setPosition(ccp(s.width/2, s.height/2));
    
    setTouchEnabled(true);
}
CCMenuItemImage * GafFeatures::addBtn(const char * text, float px, float py, SEL_MenuHandler handler, float k)
{
	CCSize size = CCDirector::sharedDirector()->getWinSize();
	
	CCMenuItemImage *res = CCMenuItemImage::create(
														  "CloseNormal.png",
														  "CloseSelected.png",
														  this,
														  handler );
    res->setPosition( ccp(size.width * px, size.height * py) );
	res->setScale(k);
	
	CCLabelTTF* pLabel = CCLabelTTF::create(text, "Thonburi", 34);
	pLabel->setColor(ccc3(0, 0, 255));
	
	pLabel->setAnchorPoint(CCPoint(1, 0.5));
	pLabel->setScale(k);
    pLabel->setPosition( ccp(res->getPositionX() - res->getContentSize().width * k * 0.5, res->getPositionY()) );
    addChild(pLabel, 100000);
	return res;
}
Beispiel #18
0
bool CSSeacraft::init()
{
	SEACRAFT * pSeaCraft = DataManager::sharedDataManager()->FindSeaCraft(m_id);
	if (!pSeaCraft)
	{
		return false;
	}
	
	m_nPos = pSeaCraft->position;
	POSITION *pPos = DataManager::sharedDataManager()->FindPostion(m_nPos);
	if (pPos)
	{
		setPosition(ccp(pPos->x, pPos->y));
	}	
	
	CCLabelTTF *pLabel = CCLabelTTF::labelWithString(pSeaCraft->pCargo->pStock->seaCraftName.c_str(), "Airal", 20);
	addChild(pLabel, ZORDER_DEFAULT);
	pLabel->setPosition(ccp(pLabel->getContentSize().width/2, 0));

	return true;
}
void ResumeTest::onEnter()
{
    ActionManagerTest::onEnter();

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

    CCLabelTTF* l = CCLabelTTF::labelWithString("Grossini only rotate/scale in 3 seconds", "Thonburi", 16);
    addChild(l);
    l->setPosition( CCPointMake(s.width/2, 245));

    CCSprite* pGrossini = CCSprite::spriteWithFile(s_pPathGrossini);
    addChild(pGrossini, 0, kTagGrossini);
    pGrossini->setPosition(CCPointMake(s.width / 2, s.height / 2));

    pGrossini->runAction(CCScaleBy::actionWithDuration(2, 2));

    CCActionManager::sharedManager()->pauseTarget(pGrossini);
    pGrossini->runAction(CCRotateBy::actionWithDuration(2, 360));

    this->schedule(schedule_selector(ResumeTest::resumeGrossini), 3.0f);
}
//------------------------------------------------------------------
//
// RemoveTest
//
//------------------------------------------------------------------
void RemoveTest::onEnter()
{
    ActionManagerTest::onEnter();

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

    CCLabelTTF* l = CCLabelTTF::labelWithString("Should not crash", "Thonburi", 16);
    addChild(l);
    l->setPosition( CCPointMake(s.width/2, 245) );

    CCMoveBy* pMove = CCMoveBy::actionWithDuration(2, CCPointMake(200, 0));
    CCCallFunc* pCallback = CCCallFunc::actionWithTarget(this, callfunc_selector(RemoveTest::stopAction));
    CCActionInterval* pSequence = (CCActionInterval*) CCSequence::actions(pMove, pCallback, NULL);
    pSequence->setTag(kTagSequence);

    CCSprite* pChild = CCSprite::spriteWithFile(s_pPathGrossini);
    pChild->setPosition(CCPointMake(200, 200));

    addChild(pChild, 1, kTagGrossini);
    pChild->runAction(pSequence);
}
Beispiel #21
0
FC_Block * FC_Block::BlockWithFile(char* szFile, int idx, FC_Main* pMainLayer)
{
    FC_Block * pBlock = new FC_Block();
	pBlock->initWithFile(szFile);
    pBlock->autorelease();
	pBlock->setTag(idx);

	char temp[10] = {0,};
	sprintf( temp, "%d", idx );

	// 블럭위에 라벨을 생성.
	CCLabelTTF* pLabel = CCLabelTTF::create(temp, "Arial", 40);
	pLabel->setPosition(ccp(30, 30));
	pLabel->setVisible( false );
	pLabel->setColor( ccBLUE );

	pBlock->addChild(pLabel, 1, 50);
	pBlock->m_pMainLayer = pMainLayer;

    return pBlock;
}
bool GameSprite_Rice::init()
{
    if (!CCSprite::init()) {
        return false;
    }
    this->setContentSize(CCSize(500, 70));
    addRiceTime = RICEADDTIME;
    riceNum = 0;
    nowTime = 0;
    nowTime = this->getCurrentTime();
    //字体背景.
    CCMenuItemImage *labelBgSprite = CCMenuItemImage::create();
    labelBgSprite->setNormalSpriteFrame(GameShare_Texture::sharedTexture()->GetSpriteFrameByCCRect(akoomenu_image, CCRect(1763, 255, 120, 49)));
    labelBgSprite->setAnchorPoint(CCPointZero);
    labelBgSprite->setPosition(CCPointZero);
    labelBgSprite->setTag(Key_Add);
    CCMenu* pMenu = CCMenu::create(labelBgSprite, NULL);
    pMenu->setPosition(ccp(300,0));
    pMenu->setTag(Key_Add);
    this->addChild(pMenu);
    
    //时间标签.
    CCLabelTTF *timeLabel = CCLabelTTF::create("", "Arial", 20);
    ccColor3B color = ccc3(95, 46, 33);
    char strTime[32];
    sprintf(strTime,"%d:%d%d",addRiceTime/60,addRiceTime%60/10,addRiceTime%60%10);
    timeLabel->setColor(color);
    timeLabel->setString(strTime);
    timeLabel->setTag(Key_Time);
    timeLabel->setPosition(ccp(pMenu->getPositionX()+40, pMenu->getPositionY()+20));
    this->addChild(timeLabel);
    //饭的背景
    CCSprite *riceBgSprite = GameShare_Texture::sharedTexture()->GetSpriteByCCRect(akoomenu_image, CCRect(1, 1570, 278, 30));
    riceBgSprite->setAnchorPoint(CCPointZero);
    riceBgSprite->setPosition(ccp(0,5));
    this->addChild(riceBgSprite);
    
    this->schedule(schedule_selector(GameSprite_Rice::timeUpdate), 1.0);
    return true;
}
bool GameSprite_Gold::init()
{
    if (!CCSprite::init()) {
        return false;
    }
    //设置大小.
    this->setContentSize(CCSize(200, 70));
    goldNum = 0;
    //字体背景.
    CCSprite *labelBgSprite = GameShare_Texture::sharedTexture()->GetSpriteByCCRect(akoomenu_image, CCRect(324, 938, 166, 48));
    labelBgSprite->setAnchorPoint(CCPointZero);
    labelBgSprite->setPosition(ccp(40,0));
    this->addChild(labelBgSprite,1);
    
    //加号
    CCSprite *addSprite = GameShare_Texture::sharedTexture()->GetSpriteByCCRect(akoomenu_image, CCRect(1970,1772,30,34));
    addSprite->setAnchorPoint(CCPointZero);
    addSprite->setPosition(ccp(185,30));
    this->addChild(addSprite,1);
    
    //金币
    CCSprite *goldSprite = GameShare_Texture::sharedTexture()->GetSpriteByCCRect(akoomenu_image, CCRect(1976, 474, 68, 68));
    goldSprite->setAnchorPoint(CCPointZero);
    goldSprite->setPosition(CCPointZero);
    this->addChild(goldSprite,1);
    
    
    CCLabelTTF *numLabel = CCLabelTTF::create("", "Arial", 25);
//    numLabel
    char strScore[32];
    sprintf(strScore,"%ld",goldNum);
    numLabel->setString(strScore);
    numLabel->setPosition(CCPoint(90, 20));
    numLabel->setTag(Key_Gold_Num);
    this->addChild(numLabel,1);
    
    
    
    return true;
}
Beispiel #24
0
bool HighScore::init()
{
	if( !CCLayer::init() )
	{
		return false;
	}

	m_nMaxHighScores = 5;
	m_nHighScoreFontSize = 40;
	m_nHighScoreFontSpacing = 20;

	m_HighScoreLabels.clear();

	CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
										"CloseNormal.png",
										"CloseSelected.png",
										this,
										menu_selector(HighScore::menuCloseCallback) );
	pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );

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

	CCLabelTTF* pLabel = CCLabelTTF::create("High Scores", "fonts/Roboto-Regular.ttf", 34);
	CCSize size = CCDirector::sharedDirector()->getWinSize();
	pLabel->setPosition( ccp( size.width / 2, size.height - 20 ) );
	this->addChild(pLabel, 1);

	createMenu();
	createFunctionsMenu();
	PopulateHighScores();

	if( SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying() )
	{
		SimpleAudioEngine::sharedEngine()->stopBackgroundMusic();
	}

	return true;
}
Beispiel #25
0
AnimatedMenuItem* SettingScene::createButton(CCSprite* logo,
                                SEL_MenuHandler ptr,
                                CCPoint& position,
                                const char* button_text,
                                const ccColor3B& color)
{
    AnimatedMenuItem* button = AnimatedMenuItem::create(
                logo, this, ptr);

    button->addChild(logo);

    button->setPosition(position);
    logo->setPosition(ccp(logo->getContentSize().width/2,
                               logo->getContentSize().height/2));


    if(button_text[0] != '\0')
    {
        const CCSize VISIBLE_SIZE = Screen::getVisibleSize();
        CCLabelTTF * dev = CCLabelTTF::create(button_text,
                                                Fonts::getFontName(),
                                                60);

        if(dev->getContentSize().width >= VISIBLE_SIZE.width)
            dev->setFontSize(40);

        dev->setPosition(ccp(logo->getContentSize().width/2,
                               logo->getContentSize().height/2));
        dev->setColor(color);
        button->addChild(dev);
    }
    else
    {
        logo->setColor(color);
    }

    _main_menu->addChild(button);

    return button;
}
Beispiel #26
0
bool CreditsScene::init()
{
    //////////////////////////////
    // 1. super init primero
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    setMenuBackMenu();

    // ** Titulo **
    CCLabelTTF* pLabel = CCLabelTTF::create("Zombies!!! El Juego", "Arial", FONT_SIZE);
    pLabel->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y - pLabel->getContentSize().height - 10));
    addChild(pLabel, 1);
    // ** FIN Titulo **

    // ** Logo **
    CCSprite* pSprite = CCSprite::create("ugr_logo.png");
    pSprite->setPosition( ccp(VisibleRect::center().x, VisibleRect::center().y + 10) );
    addChild(pSprite, 0);
    // ** FIN Logo **
    
    // ** Creadores **
    pLabel = CCLabelTTF::create("Artica Media, C.A.", "Arial", FONT_SIZE - 5);
    pLabel->setPosition(ccp(VisibleRect::bottom().x, VisibleRect::bottom().y + pLabel->getContentSize().height - 5));
    addChild(pLabel, 1);

    pLabel = CCLabelTTF::create("José Sánchez", "Arial", FONT_SIZE - 5);
    pLabel->setPosition(ccp(VisibleRect::bottom().x, VisibleRect::bottom().y + pLabel->getContentSize().height*2 - 5*2));
    addChild(pLabel, 1);

    pLabel = CCLabelTTF::create("Héctor Domínguez", "Arial", FONT_SIZE - 5);
    pLabel->setPosition(ccp(VisibleRect::bottom().x, VisibleRect::bottom().y + pLabel->getContentSize().height*3 - 5*3));
    addChild(pLabel, 1);

    pLabel = CCLabelTTF::create("José Piñero", "Arial", FONT_SIZE - 5);
    pLabel->setPosition(ccp(VisibleRect::bottom().x, VisibleRect::bottom().y + pLabel->getContentSize().height*4 - 5*4));
    addChild(pLabel, 1);

    pLabel = CCLabelTTF::create("Creadores:", "Arial", FONT_SIZE);
    pLabel->setPosition(ccp(VisibleRect::bottom().x, VisibleRect::bottom().y + pLabel->getContentSize().height*5 - 5*8));
    addChild(pLabel, 1);
    // ** FIN Creadores **

    return true;
}
CCMenuItemSprite* CCLayerParent::getSpriteButton(int tag,int price,const char* frameName,SEL_MenuHandler selector)
{	
 	CCSize winSize = CCDirector::sharedDirector()->getWinSize();

    CCMenuItemSprite *quirkButton =  CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("spawn.png"),CCSprite::createWithSpriteFrameName("spawn_sel.png"),this,selector);
    CCSize contentSize =  quirkButton->getContentSize();
	//quirkButton->setPosition (ccp(contentSize.width* tag, contentSize.height/2));
	quirkButton->setTag(tag);
    CCSprite* quirk = CCSprite::createWithSpriteFrameName(frameName);
	quirk->setPosition(ccp(quirk->getContentSize().width/2, contentSize.height-quirk->getContentSize().height/2));
    quirkButton->addChild(quirk);
    char temp[64];
    sprintf(temp, "%d", price);

    //CCLabel* quirkLabel = CCLabelBMFont::create(temp,"Courier_green.fnt");
	CCLabelTTF* quirkLabel = CCLabelTTF::create(temp, "Helvetica-Bold", fontSizeBig, ccp(xMARGIN,yMARGIN), kCCTextAlignmentCenter );
	quirkLabel->setColor(ccc3(255,255,255));
    quirkLabel->setPosition(ccp(quirk->getContentSize().width/2, yMARGIN*0.4));
    quirkButton->addChild(quirkLabel);
	quirkButton->setZOrder(3);
	return quirkButton;
}
Beispiel #28
0
bool DebugTestScene::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }

    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin     = CCDirector::sharedDirector()->getVisibleOrigin();

    //  タイトル名表示
    CCLabelTTF* pTitleLabel = NULL;
    {
        pTitleLabel = CCLabelTTF::create("DebugScene", "Arial", MultiResolution::shared()->getFontSize(24));

        pTitleLabel->setPosition(ccp(origin.x + visibleSize.width/2,
                                origin.y + visibleSize.height - pTitleLabel->getContentSize().height));
        
        addChild(pTitleLabel, 1);
    }
    
    //  テーブルビュー作成
    {
        CCTableView*    pTableView  =
            CCTableView::create(this, CCSizeMake(visibleSize.width, visibleSize.height));
        
        pTableView->setDirection(kCCScrollViewDirectionVertical);
        pTableView->setVerticalFillOrder(kCCTableViewFillTopDown);
        pTableView->setPosition(ccp(origin.x, origin.y - pTitleLabel->getContentSize().height * 2));
        pTableView->setDelegate(this);

        addChild(pTableView, 2);
        
        //  テーブルビューのデータを読み込み
        pTableView->reloadData();
    }
    
    return true;
}
Beispiel #29
0
void MainGameScene::showGameCountLabel()
{
    
    CCString* countString = CCString::createWithFormat("%d",totalGameCount);
    
    CCSprite* pTouchWaku = (CCSprite*)this->getChildByTag(tagTouchWaku);
    if(pTouchWaku){
         CCLabelTTF* countLabel = (CCLabelTTF*)pTouchWaku->getChildByTag(tagGameCountLavel);
        if(countLabel){
             countLabel->setString(countString->getCString());
            return;
        }
    }else{
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        
        CCSprite* pTouchWaku= CCSprite::create("touch_waku.png");
        pTouchWaku->setScale(0.5);
        CCSize pTouchSize = pTouchWaku->getContentSize();
        pTouchWaku->setPosition(ccp(winSize.width - pTouchSize.width * 0.4, winSize.height - pTouchSize.height * 0.4));
        pTouchWaku->setTag(tagTouchWaku);
        
       
        CCLabelTTF* countLabel;
        countLabel = CCLabelTTF::create(countString->getCString(), "Arial", 80.0);
        countLabel->setPosition(ccp(pTouchSize.width * 0.5, pTouchSize.height * 0.6));
        countLabel->setColor(ccc3(0, 0, 0));
        countLabel->setTag(tagGameCountLavel);
        
        CCLabelTTF* countLabel2;
        countLabel2 = CCLabelTTF::create("touch", "Arial", 50.0);
        countLabel2->setPosition(ccp(pTouchSize.width * 0.5, pTouchSize.height * 0.3));
        countLabel2->setColor(ccc3(0, 0, 0));
        
        
        pTouchWaku->addChild(countLabel);
        pTouchWaku->addChild(countLabel2);
        this->addChild(pTouchWaku);
    }
}
Beispiel #30
0
CCTableViewCell* MainScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCString *string = CCString::createWithFormat("%d", idx);
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell) {
        cell = new CCTableViewCell();
        cell->autorelease();
        CCSprite *sprite = CCSprite::create("Icon-144.png");
        sprite->setAnchorPoint(CCPointZero);
        sprite->setPosition(ccp(0, 0));
        sprite->setScaleX(2);
        cell->addChild(sprite);
        
        CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", 20.0);
        label->setPosition(CCPointZero);
        label->setAnchorPoint(CCPointZero);
        label->setTag(123);
        cell->addChild(label);
        
        CCMenuItemImage *pBtn = CCMenuItemImage::create(
                                                        "CloseNormal.png",
                                                        "CloseSelected.png",
                                                        this,
                                                        menu_selector(MainScene::tableViewSubBtnCallback));
        CCMenu* pMenu = CCMenu::create(pBtn, NULL);
        pBtn->setPosition(ccp(pBtn->getContentSize().width/2,pBtn->getContentSize().height/2));
        pMenu->setPosition(CCPointZero);
        cell->addChild(pMenu, 1);
        cell->setTag(idx);
    }
    else
    {
        CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
        label->setString(string->getCString());
    }

    
    return cell;
}