当前位置: 首页>>代码示例>>C++>>正文


C++ CCLabelTTF::setAnchorPoint方法代码示例

本文整理汇总了C++中CCLabelTTF::setAnchorPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::setAnchorPoint方法的具体用法?C++ CCLabelTTF::setAnchorPoint怎么用?C++ CCLabelTTF::setAnchorPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCLabelTTF的用法示例。


在下文中一共展示了CCLabelTTF::setAnchorPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: initHero

void FairyControlPanel::initHero(FairyHero* selectHero){
	controlType = 2;
	panelBack->removeAllChildrenWithCleanup(true);
	CCSize size = panelBack->getContentSize();
	int ids[4] = {-1, -1, -1, -1};
	for(int i = 0; i < (int)selectHero->skillIds.size(); i++){
		ids[i] = selectHero->skillIds.at(i);
	}
	CCString* SkillDataFile;
	XMLParser *skillData;
	CCMenu* menu = CCMenu::create();
	if(ids[0] != -1){
		SkillDataFile = CCString::createWithFormat("data/skill%d.xml",ids[0]);
		skillData = XMLParser::parseWithFile(SkillDataFile->getCString());
		CCSprite* skill1 = CCSprite::create(skillData->getString("skillIcon")->getCString());
		CCMenuItemSprite*skill1Button = CCMenuItemSprite::create(skill1, skill1, this, menu_selector(FairyControlPanel::fairyMenuCallback));
		skill1Button->setTag(leftDrection);
		skill1Button->setPosition(ccp(size.width / 8, size.height / 2 + 30));
		menu->addChild(skill1Button);
	}
	if(ids[1] != -1){
		SkillDataFile = CCString::createWithFormat("data/skill%d.xml",ids[1]);
		skillData = XMLParser::parseWithFile(SkillDataFile->getCString());
		CCSprite* skill1 = CCSprite::create(skillData->getString("skillIcon")->getCString());
		CCSprite* skill2 = CCSprite::create(uiLeftNormal);
		CCMenuItemSprite* skill2Button = CCMenuItemSprite::create(skill2, skill2, this, menu_selector(FairyControlPanel::fairyMenuCallback));
		skill2Button->setTag(holdDrection);
		skill2Button->setPosition(ccp(2 * size.width / 8, size.height / 2+ 30));
		menu->addChild(skill2Button);
	}
	if(ids[2] != -1){
		SkillDataFile = CCString::createWithFormat("data/skill%d.xml",ids[2]);
		skillData = XMLParser::parseWithFile(SkillDataFile->getCString());
		CCSprite* skill1 = CCSprite::create(skillData->getString("skillIcon")->getCString());
		CCSprite* skill3 = CCSprite::create(uiLeftNormal);
		CCMenuItemSprite* skill3Button = CCMenuItemSprite::create(skill3, skill3, this, menu_selector(FairyControlPanel::fairyMenuCallback));
		skill3Button->setTag(rightDrection);
		skill3Button->setPosition(ccp(3 * size.width / 8, size.height / 2 + 30));
		menu->addChild(skill3Button);
	}
	if(ids[3] != -1){
		SkillDataFile = CCString::createWithFormat("data/skill%d.xml",ids[3]);
		skillData = XMLParser::parseWithFile(SkillDataFile->getCString());
		CCSprite* skill4 = CCSprite::create(skillData->getString("skillIcon")->getCString());
		CCMenuItemSprite* skill4Button = CCMenuItemSprite::create(skill4, skill4, this, menu_selector(FairyControlPanel::fairyMenuCallback));
		skill4Button->setTag(upDrection);
		skill4Button->setPosition(ccp(4 * size.width / 8, size.height / 2 + 30));
		menu->addChild(skill4Button);
	}
	panelBack->addChild(menu);
	menu->setPosition(ccp(0, - 30));
	CCString* heroDataFile = CCString::createWithFormat("data/hero%d.xml",selectHero->heroId / 10 * 10);
	XMLParser *heroData = XMLParser::parseWithFile(heroDataFile->getCString());
	CCLabelTTF* heroName = CCLabelTTF::create(heroData->getString("name")->getCString(), "Arial", 50);
	heroName->setColor(ccc3(0x00, 0x00, 0x00));
	heroName->setAnchorPoint(ccp(0,1));
	heroName->setPosition(ccp( 5 * size.width / 8, size.height / 2 + 30));
	panelBack->addChild(heroName);
}
开发者ID:fairysmile,项目名称:cocos2d-x,代码行数:59,代码来源:FairyControlPanel.cpp

示例2: CCListView_cellForRow

void ActivityView::CCListView_cellForRow(CCListView *listView, CCListViewProtrolData *data) 
{
	// 背景
	CCSprite* cellBg = CCSprite::create("bg_listview_item.png") ;

	const float cell_width = cellBg->getContentSize().width+15 ;
	const float cell_height = cellBg->getContentSize().height+10 ;

	CCListViewCell* cell = CCListViewCell::node() ;
	cell->setContentSize(CCSizeMake(cell_width, cell_height)) ;
	cell->setOpacity(0) ;
	// cell->setSelectionColor(ccc4(255, 0, 0, 255)) ;
	cell->setSelectionColor(ccc4(103, 102, 204, 255)) ;
	data->cell = cell ;

	CCNode* cellNode = CCNode::create() ;
	cellNode->setContentSize(CCSizeMake(cell_width, cell_height)) ;
	cellNode->setAnchorPoint(ccp(0, 0)) ;
	cellNode->setPosition(ccp(0, 0)) ;
	cell->addChild(cellNode) ;

	// 背景
	cellBg->setAnchorPoint(ccp(0.5, 0.5)) ;
	cellBg->setPosition(ccp(cell_width*0.5, cell_height*0.5)) ;
	cellNode->addChild(cellBg) ;

	// icon
	CCSprite* iconMsg = CCSprite::create("icon_activity.png") ;
	iconMsg->setAnchorPoint(ccp(0, 0.5)) ;
	iconMsg->setPosition(ccp(cell_width-90, cell_height*0.5)) ;
	cellNode->addChild(iconMsg, 1) ;

	// 主题
	CCLabelTTF* themeLabel = CCLabelTTF::create("蛇年贺新春,免费拿九玩币","font01.ttf", 24.0f,CCSizeMake(cell_width, 50),
									kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter) ;
	themeLabel->setColor(ccc3(255, 215, 0)) ;
	themeLabel->setAnchorPoint(ccp(0, 1)) ;
	themeLabel->setPosition(ccp(20, cell_height-8)) ;
	cellNode->addChild(themeLabel, 1) ;
	
	// 内容
	CCLabelTTF* contentLabel = CCLabelTTF::create("蛇年贺新春,免费拿九玩币,蛇年贺新春,免费拿九玩币", "font01.ttf", 20.0f,CCSizeMake(cell_width, 50),kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter) ;
	contentLabel->setAnchorPoint(ccp(0, 0)) ;
	contentLabel->setPosition(ccp(20, 8)) ;
	cellNode->addChild(contentLabel, 1) ;
}
开发者ID:fengmm521,项目名称:qipaiproject,代码行数:46,代码来源:ActivityView.cpp

示例3: addElements

void StatusUpgrade::addElements(std::string name, CCPoint position){
    CCLabelTTF* strength = CCLabelTTF::create(name.c_str(), "Thonburi", 10);
    strength->setAnchorPoint(ccp(0,0.5));
    strength->setPosition(ccp(30, position.y));
    strength->setColor(ccc3(0,0,0));
    this->addChild(strength, 1);
    
    CCLabelTTF* currentLabel = CCLabelTTF::create(CCString::createWithFormat("%d", this->_current)->getCString(), "arial", 10);
    currentLabel->setAnchorPoint(ccp(0,0.5));
    currentLabel->setPosition(ccp(90, position.y));
    currentLabel->setColor(ccc3(0,0,0));
    this->addChild(currentLabel);
    
    char* desc = this->getDescription(name);
    CCLabelTTF* description = CCLabelTTF::create(desc, "Thonburi", 8);
    description->setAnchorPoint(ccp(0,0.5));
    description->setPosition(ccp(35, position.y - 20));
    description->setColor(ccc3(0,0,0));
    this->addChild(description);
    
    afterLabel   = CCLabelTTF::create(CCString::createWithFormat("-> %d", this->_current + this->_currentAddition)->getCString(), "arial", 10);
    afterLabel->setAnchorPoint(ccp(0, 0.5));
    afterLabel->setPosition(ccp(120, position.y));
    afterLabel->setColor(ccc3(0,0,0));
    this->addChild(afterLabel);
    
    CCSprite* plus = CCSprite::createWithSpriteFrameName("plus.png");
    CCSprite* plusOff = CCSprite::createWithSpriteFrameName("plus.png");
    plusOff->setColor(ccc3(102,102,102));
    CCMenuItemSprite* pPlusButton =
        CCMenuItemSprite::create(plus, plusOff, this, menu_selector(StatusUpgrade::plus));
    
    CCSprite* minus = CCSprite::createWithSpriteFrameName("minus.png");
    CCSprite* minusOff = CCSprite::createWithSpriteFrameName("minus.png");
    minusOff->setColor(ccc3(102,102,102));
    CCMenuItemSprite* pMinusButton =
        CCMenuItemSprite::create(minus, minusOff, this, menu_selector(StatusUpgrade::minus));
    
    pPlusButton->setPosition(ccp(position.x - 90, position.y));
    pMinusButton->setPosition(ccp(position.x - 50, position.y));
    CCMenu* pMenu = CCMenu::create(pPlusButton, pMinusButton, NULL);
 //   pMenu->setTouchPriority(kLevelUpLayerMenuPriority);
    pMenu->setPosition(CCPointZero);
    
    this->addChild(pMenu);
}
开发者ID:sukesan1984,项目名称:diabloraid,代码行数:46,代码来源:StatusUpgrade.cpp

示例4: tableCellAtIndex

CCTableViewCell* RankingScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCTableViewCell *cell = table->dequeueCell();
    cell = new CCTableViewCell();
    cell->autorelease();
    
    // Player Point
    Player * p = (Player*)players->objectAtIndex(idx);
    CCString *string = CCString::createWithFormat("%d",p->getPoint());
    CCLabelTTF *Pointlabel = CCLabelTTF::create(string->getCString(), "Helvetica", 48);
    Pointlabel->setAnchorPoint(ccp(1, 0));
    Pointlabel->setPosition(ccp(500,0));
    Pointlabel->setTag(123);
    cell->addChild(Pointlabel);
    // Player Name
    std::string name = p->getName();
    CCLabelTTF *Namelabel = CCLabelTTF::create(p->getName().c_str(), "Helvetica", 48);
    Namelabel->setAnchorPoint(CCPointZero);
    Namelabel->setPosition(ccp(100, 0));
    cell->addChild(Namelabel);
    
    // Player Rank
    char rankBuf[3];
    sprintf(rankBuf, "%i.png", idx+1);
    CCSprite *rank = CCSprite::create(rankBuf);
    rank->setAnchorPoint(CCPointZero);
    rank->setPosition(CCPointZero);
    cell->addChild(rank);
    
    if (idx == 0) {
        int rewardLocal = CCUserDefault::sharedUserDefault()->getIntegerForKey("reward");
        std::string nameLocal = GameManager::sharedGameManager()->getName();
        int pointMax = CCUserDefault::sharedUserDefault()->getIntegerForKey("pointMax");
        if (p->getReward() != 0 && rewardLocal != 0 &&
            p->getName() == nameLocal && p->getPoint() == pointMax) {
            CCMenuItemImage *bt_send_email =
                CCMenuItemImage::create("Present.png","Present.png",
                                        this, menu_selector(RankingScene::clickBtSendEmail));
            CCMenu * menu = CCMenu::create(bt_send_email, NULL);
            menu->setPosition(ccp(550, 30));
            cell->addChild(menu);
        }
        
    }
    return cell;
}
开发者ID:ngocdu,项目名称:AirHockey2,代码行数:46,代码来源:RankingScene.cpp

示例5: init

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

    // 2. load texture
    cocos2d::CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("GameScene.plist");
    
    // init basic data
    runDistance = 0.0f;
    coinCount = 0;
    prevPos = CCPointZero;
    isGameStart = false;
    isGameEnd = false;
    isRunning = false;
    isSliding = false;
    isJumpping = false;
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();

    // init map nodes
    for (int i = 0; i < kGameMapCount; i ++) {
        CCNode *mapNode = CCNode::create();
        this->addChild(mapNode, MapBottomZorder, MapStartTag + i);
        mapNode->setPosition(ccp(0, winSize.height * i));
        this->initMapNode(mapNode);
        this->resetMapNode(mapNode);
    }
    
    // init map barrier node
    for (int i = 0; i < kGameMapCount; i ++) {
        CCNode *barrierNode = CCNode::create();
        this->addChild(barrierNode, MapBarrierZorder, MapBarrierStartTag + i);
        barrierNode->setPosition(ccp(0, winSize.height * i));
        this->initBarrierNode(barrierNode);
        this->resetBarrierNode(barrierNode, MapBarrierStartTag + i);
    }
    
    // init player
    CCSprite *playerSprite = CCSprite::createWithSpriteFrameName("Role.png");
    playerSprite->setPosition(ccp(kGameMapSecondRoad, kPlayerStartAtScreenPosY));
    this->addChild(playerSprite, PlayerZorder, PlayerTag);
    
    // init score
    CCLabelTTF *scoreLabel = CCLabelTTF::create("score: 0", "Helvetica", 24);
    scoreLabel->setAnchorPoint(ccp(0.0f, 0.5f));
    scoreLabel->setPosition(ccp(50.0f, winSize.height - 20.0f));
    this->addChild(scoreLabel, ScoreLabelZorder, ScoreLabelTag);
    
    // touch enabled
    this->setTouchEnabled(true);
    
    return true;
}
开发者ID:cqnature,项目名称:testrungame,代码行数:59,代码来源:GameLayer.cpp

示例6: CustomTableViewCell

CCTableViewCell* S11PrepareRes::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell)
    {
        cell = new CustomTableViewCell();
        cell->autorelease();
        if (idx==0)
        {
            selectIndex=0;
        
        }
   
        CCLabelTTF *label = CCLabelTTF::create("点击输入", "Helvetica", 30.0);
        label->setColor(ccBLACK);
        label->setPosition(s11Position8_1_macro(label));
        label->setAnchorPoint(CCPointZero);
        label->setTag(123);
        cell->addChild(label,101);
        
        CCSprite *pSprite = CCSprite::create("s11CellDivideLine.png");
        pSprite->setAnchorPoint(CCPointZero);
		pSprite->setPosition(CCPointZero);
        cell->addChild(pSprite,101);
  
    }
    else
    {
        if (selectIndex ==idx)
        {
            if (activeSprite)
            {
                activeSprite->removeFromParentAndCleanup(false);
            }

            
            activeSprite = CCSprite::create("s11Active Bar.png");
            activeSprite->setAnchorPoint(CCPointZero);
            activeSprite->setPosition(CCPointZero);
            cell->addChild(activeSprite,99);
        }
        
         CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
        CCString *aString = CCString::createWithFormat("%u",idx+1);
        std::string aStr = aString->m_sString;
        std::map<std::string,std::string>::iterator aIterator = scriptMap.find(aStr);
        std::string aStr2;
        if (aIterator !=scriptMap.end())
        {
            aStr2 = aIterator->second;
        }
        
        label->setString(aStr2.c_str());
  
    }
    
    return cell;
}
开发者ID:liuyuyefz,项目名称:GreTest,代码行数:58,代码来源:S11PrepareResScene.cpp

示例7: setUpView

void TimeLayer::setUpView()
{
	//label
	CCLabelTTF *lb = CCLabelTTF::create("Time : 0","arial",24);
	lb->setAnchorPoint(CCPointZero);
	lb->setPosition(CCPointZero);

	this->addChild(lb,0,15);
}
开发者ID:nawenqiang,项目名称:aircraft,代码行数:9,代码来源:TimeLayer.cpp

示例8: init

bool MainMenu::init()
{
	if ( !CCLayerColor::initWithColor(ccc4(0, 0, 0, 200)) )
    {
        return false;
    }

	CCLabelTTF *title = CCLabelTTF::create("Rabbit Run", FONT_NAME, 70);
	title->setPosition(ccp(SCREEN_CX, SCREEN_HEIGHT - 80));
	this->addChild(title);

	CCMenuItemFont::setFontName(FONT_NAME);
	CCMenuItemFont::setFontSize(50);

	char* text[] = {"Score", "Power", "Effect",
				   "+10", "+20%", "--",
	               "+20", "+40%", "grow up",
				   "+10", "+0", "lose weight",
	               "+0", "+0","hiding"};
	for(int i = 0; i < 15; i++)
	{
		CCLabelTTF *label = CCLabelTTF::create(text[i], FONT_NAME, 50);
		label->setPosition(ccp(400 + i%3*300, 550 - i/3*85));
		this->addChild(label);
	}
	char* img[] = {"cabbage.png", "carrot.png", "carrot_ice.png", "carrot_sterlth.png"};
	for(int i = 0; i < 4; i++)
	{
		CCSprite *sprite = CCSprite::create(img[i]);
		sprite->setScale(0.2f);
		sprite->setPosition(ccp(250, 450 - i*80));
		this->addChild(sprite);
	}
	CCMenuItemFont *startGame = CCMenuItemFont::create("Play", this, menu_selector(MainMenu::startGame));
	startGame->setColor(ccc3(0, 255,51));
	startGame->setPositionX(-90);

	CCMenuItemFont *exitGame = CCMenuItemFont::create("Exit", this, menu_selector(MainMenu::exitGame));
	exitGame->setColor(ccc3(255, 0, 0));
	exitGame->setPositionX(110);

	CCMenu *menu = CCMenu::create(startGame, exitGame, NULL);
	menu->setPositionY(120);
	menu->setTouchPriority(-201);
	this->addChild(menu);

	CCLabelTTF *powerBy = CCLabelTTF::create("Power by cocos2d-x", FONT_NAME, 50);
	powerBy->setAnchorPoint(ccp(1, 0));
	powerBy->setPosition(ccp(SCREEN_WIDTH, 0));
	this->addChild(powerBy);

	this->setTouchPriority(-200);
	this->setTouchMode(kCCTouchesOneByOne);
	this->setTouchEnabled(true);

	return true;
}
开发者ID:DanicaMeng,项目名称:RabbitRun,代码行数:57,代码来源:MainMenu.cpp

示例9: addChild

TestController::TestController()
    : m_tBeginPos(CCPointZero)
{

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

    CCSprite * pbackground = CCSprite::spriteWithFile("metrobackground.png");
    pbackground->setPosition(CCPointMake(s.width/2,s.height/2));
    //addChild(pbackground);
    // add close menu
    CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(s_pPathClose, s_pPathClose, this, menu_selector(TestController::closeCallback) );
    CCMenu* pMenu =CCMenu::menuWithItems(pCloseItem, NULL);
    pMenu->setPosition( CCPointZero );
    pCloseItem->setPosition(CCPointMake( 30, s.height - 50));
    // add title COCOS2S-X
    CCLabelTTF* title = CCLabelTTF::labelWithString("COCOS2D-X-Metro", "Arial", 24);
    title->setAnchorPoint(CCPointMake(0,0.5));
    title->setPosition(CCPointMake(72,s.height - 50));
    addChild(title);
    // Load TestIcons
    CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
    cache->addSpriteFramesWithFile("metroIcons.plist", "metroIcons.png");
    char tmp[50];
    // add menu items for tests
    m_pItmeMenu = CCMenu::menuWithItems(NULL);
    int colorscount = sizeof(ccMetroColors) / sizeof(ccColor4B);

    for (int i = 0; i < TESTS_COUNT; ++i)
    {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
        CCLabelBMFont* label = CCLabelBMFont::labelWithString(g_aTestNames[i].c_str(),  "fonts/arial16.fnt");
#else
        CCLabelTTF* label = CCLabelTTF::labelWithString(g_aTestNames[i].c_str(), "Arial", 24);
#endif
        // Create Metro MenuItem
        CCMenuItemMetro* pMenuItem = CCMenuItemMetro::itemWithMetro(label, this, menu_selector(TestController::menuCallback));
        pMenuItem->setAnchorPoint(CCPointMake(0,0));
        pMenuItem->setMetroSlyte(ccMetroColors[i % colorscount]);
        m_pItmeMenu->addChild(pMenuItem, i + 10000);
        pMenuItem->setPosition(CCPointMake(70 + (i / 3) * (MetroRectW + 10),((MetroRectH + 10)* 3) - (i % 3) * (MetroRectH + 10) - 85));
        //Icons
        sprintf(tmp, "metroicon%d.png", i);
        CCSpriteFrame* frame = cache->spriteFrameByName(tmp);
        CCSprite* pIcon = CCSprite::spriteWithSpriteFrame(frame);
        pMenuItem->addChild(pIcon);
        pIcon->setPosition(CCPointMake(80,60));
    }

    m_pItmeMenu->setContentSize(CCSizeMake((TESTS_COUNT / 3 + 1) * (MetroRectW + 10) - s.width, s.height));
    m_pItmeMenu->setPosition(s_tCurPos);
    addChild(m_pItmeMenu);

    setIsTouchEnabled(true);

    addChild(pMenu, 1);
}
开发者ID:Openxlive,项目名称:cocos2d-x-win8-tests-metro-style,代码行数:56,代码来源:controller.cpp

示例10: init

bool HomeScene::init()
{
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    CCSprite* bgSpr = CCSprite::create("home_bg.png");
    bgSpr->setAnchorPoint(ccp(0, 0));
    bgSpr->setPosition( ccp(0, size.height-960) );
    this->addChild(bgSpr, -1, 0);
    
    HomeLayer* layer = new HomeLayer();
    layer->initWithDelegate(this);
    this->addChild(layer);
    
    //下导航区域
    CCMenuItemImage *bu01 = CCMenuItemImage::create("zhuye.png", "zhuye.png", this, menu_selector(HomeScene::menuItemCallBack));
    bu01->setTag(1);
    bu01->setPosition(ccp(60, 0));
    CCMenuItemImage *bu02 = CCMenuItemImage::create("chengshi.png", "chengshi.png", this, menu_selector(HomeScene::menuItemCallBack));
    bu02->setTag(2);
    bu02->setPosition(ccp(165, 0));
    CCMenuItemImage *bu03 = CCMenuItemImage::create("fuben.png", "fuben.png", this, menu_selector(HomeScene::menuItemCallBack));
    bu03->setTag(3);
    bu03->setPosition(ccp(270, 0));
    CCMenuItemImage *bu04 = CCMenuItemImage::create("huodong.png", "huodong.png", this, menu_selector(HomeScene::menuItemCallBack));
    bu04->setTag(4);
    bu04->setPosition(ccp(375, 0));
    CCMenuItemImage *bu05 = CCMenuItemImage::create("beibao.png", "beibao.png", this, menu_selector(HomeScene::menuItemCallBack));
    bu05->setTag(5);
    bu05->setPosition(ccp(480, 0));
    CCMenuItemImage *bu06 = CCMenuItemImage::create("shangcheng.png", "shangcheng.png", this, menu_selector(HomeScene::menuItemCallBack));
    bu06->setTag(6);
    bu06->setPosition(ccp(585, 0));
    CCMenu* menu = CCMenu::create(bu01, bu02, bu03, bu04, bu05, bu06, NULL);
    menu->setPosition(ccp(0, 60));
    menu->setAnchorPoint(ccp(0, 0.5));
    this->addChild(menu);
    
    //系统公告
    CCLabelTTF* sysLabel = CCLabelTTF::create("系统公告板:展示系统消息", "", 24.0f);
    sysLabel->setAnchorPoint( ccp(0, 0.5f) );
    sysLabel->setPosition( ccp(size.width, size.height-25) );
    this->addChild(sysLabel, 0, 100);
    //
    CCMoveBy* pMove = CCMoveBy::create(10.0f, ccp(-size.width-sysLabel->getContentSize().width, 0));
    CCAction* pStop = CCCallFuncND::create(this, callfuncND_selector(HomeScene::actionDidFinished), NULL);
    sysLabel->runAction(CCSequence::create(pMove, pStop, NULL));
    
    sysLabel->runAction(pMove);
    
    return true;
}
开发者ID:zhouxj6112,项目名称:HelloWorld-cocos2d-x-2.2.3,代码行数:56,代码来源:HomeScene.cpp

示例11: init

bool CustomPop::init(){
    if(!CCLayerColor::initWithColor(ccc4(0, 0, 0, 180))){
        return false;
    }
    
    this->setTouchEnabled(true);
    
    
    CCSize size=CCDirector::sharedDirector()->getWinSize();
    this->setContentSize(size);
    
    
    CCSprite *bkg = CCSprite::create("common_pop_bkg.png");
    bkg->setPosition(ccp(size.width/2, size.height/2)); 
    this->addChild(bkg);
    CCSize sz = bkg->getContentSize();
    
    ccColor3B black1 = ccc3(236, 190, 108);
    ccColor3B black = ccc3(27, 18, 6);
    
    CCLabelTTF* title = CCLabelTTF::create("提  示", "hycc.ttf", 28);
    title->setColor(black);
    title->setAnchorPoint(ccp(0.5, 1));
    title->setPosition(ccp(sz.width/2+1, sz.height-23));
    bkg->addChild(title);
    CCLabelTTF* title1 = CCLabelTTF::create("提  示", "hycc.ttf", 28);
    title1->setColor(black1);
    title1->setAnchorPoint(ccp(0.5, 1));
    title1->setPosition(ccp(sz.width/2, sz.height-22));
    bkg->addChild(title1);
    
    
    
    desc = CCLabelTTF::create("", "hycc.ttf", 25,CCSizeMake(400, 0),kCCTextAlignmentCenter);
    
    desc->setColor(black);
//    desc->setAnchorPoint(ccp(0.5, 1));
    desc->setPosition(ccp(sz.width/2, sz.height/2+10));
    bkg->addChild(desc);
    
    
    CCMenuItemImage* bz = CCMenuItemImage::create("common_btn_ok_1.png", "common_btn_ok_2.png", this, menu_selector(CustomPop::close));
//    bz->setAnchorPoint(ccp(0,0));
    
//    bz->setPosition(ccp(sz.width/2, 30));
    bz->setScale(1.3);
    
    btnsMenu = CCMenu::create(bz,NULL);
    btnsMenu->setPosition(ccp(sz.width/2,80));
    
    bkg->addChild(btnsMenu);
    

    return true;
}
开发者ID:GeekMobileShop,项目名称:diabloWorld,代码行数:55,代码来源:CustomPop.cpp

示例12: init

bool MainLayer::init()
{
	/*-- 设置整体层属性 --*/
	this->setTouchMode(kCCTouchesOneByOne);
	this->setTouchEnabled(true);
	this->scheduleUpdate();
	CCSize s = CCDirector::sharedDirector()->getWinSize();
	this->ignoreAnchorPointForPosition(true);
	setAnchorPoint(ccp(0.5f, 0.5f));
	this->setContentSize(s);
	setPosition(ccp(s.width / 2, s.height / 2));

	CCSize vsize = CCDirector::sharedDirector()->getVisibleSize();
	float width = vsize.width / 2;
	float height = vsize.height / 2;
	Counter *counter = Counter::sharedCounter();
	counter->clearScore();
	if (counter->isSound()
			&& !SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying())
	{
		SimpleAudioEngine::sharedEngine()->playBackgroundMusic("bgm.mp3", true);
	}
	/*-- door --*/
	CCAnimation *doorAnimation =
			CCAnimationCache::sharedAnimationCache()->animationByName("door");
	//左侧
	CCSprite *leftDoor = CCSprite::createWithSpriteFrameName("door_1.png");
	leftDoor->setPosition(ccp(-200, -50));
	leftDoor->setAnchorPoint(ccp(0.5, 0.5));
	this->addChild(leftDoor);
	leftDoor->runAction(
			CCRepeatForever::create(CCAnimate::create(doorAnimation)));

	//右侧
	CCSprite *rightDoor = CCSprite::createWithSpriteFrameName("door_1.png");
	rightDoor->setPosition(ccp(200, -50));
	rightDoor->setAnchorPoint(ccp(0.5, 0.5));
	this->addChild(rightDoor);
	rightDoor->runAction(
			CCRepeatForever::create(CCAnimate::create(doorAnimation)));

	/*-- 分数 --*/
	CCLabelTTF *titletxt = CCLabelTTF::create(counter->getStringByKey("score"),
			counter->getStringByKey("font"), 46);
	titletxt->setColor(ccc3(98, 104, 191));
	titletxt->setAnchorPoint(ccp(0.5, 0.5));
	titletxt->setPosition(ccp(0, height - 130));
	this->addChild(titletxt);
	CCNode *scoreLabel = counter->create_label();
	scoreLabel->setPosition(ccp(0, height - 200));
	scoreLabel->setAnchorPoint(ccp(0.5, 1));
	this->addChild(scoreLabel, 3, TAG_SCORE);
	/*-- role --*/
	return true;
}
开发者ID:beforeeight,项目名称:bump,代码行数:55,代码来源:MainLayer.cpp

示例13: init

/**
*	初始化方法,继承CCLayer的方法
*/
bool WelcomeView::init() 
{
	if(!CCLayer::init())
	{
		return false ;
	}

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

	// 背景
	CCSprite* downBg = CCSprite::create("bg_welcome.png") ;
	downBg->setAnchorPoint(ccp(0.5, 0)) ;
	downBg->setPosition(ccp(winSize.width/2, 0)) ;
	this->addChild(downBg, 0) ;

	
	
	// 加载logo
	CCSprite* logo = CCSprite::create("logo_01.png") ;
	logo->setAnchorPoint(ccp(0.5, 0.5)) ;
	logo->setPosition(ccp(winSize.width/2, winSize.height/2)) ;
	this->addChild(logo, 1) ;

	
	//////////////////////////// LOADING  //////////////////////////////////////////
	CCLabelTTF* loadingLabel = CCLabelTTF::create("LOADING...", "Arial", 26) ;
	loadingLabel->setAnchorPoint(ccp(0.5, 0)) ;
	loadingLabel->setPosition(ccp(winSize.width/2, 65)) ;
	loadingLabel->setHorizontalAlignment(kCCTextAlignmentCenter) ; // 水平对齐方式
	loadingLabel->setVerticalAlignment(kCCVerticalTextAlignmentCenter) ; // 垂直对齐方式
	
	this->addChild(loadingLabel, 1) ;	
	
	///////////////////////////////// 进度条 //////////////////////////////////////////
	const float margin_bottom = 38.0f ;

	// 进度条背景
	CCSprite* progressBarBg = CCSprite::create("bg_loading.png") ;
	progressBarBg->setAnchorPoint(ccp(0.5, 0)) ;
    progressBarBg->setPosition(ccp(winSize.width/2, margin_bottom));
    this->addChild(progressBarBg, 1) ;

	// 进度条
	progressBar = CCProgressTimer::create(CCSprite::create("bg_loading_icon.png"));
	progressBar->setType( kCCProgressTimerTypeBar ); //设置进度条为水平
	//    Setup for a bar starting from the left since the midpoint is 0 for the x
    progressBar->setMidpoint(ccp(0,0));
    //    Setup for a horizontal bar since the bar change rate is 0 for y meaning no vertical change
    progressBar->setBarChangeRate(ccp(1, 0)); // 设置进度条的长度和高度开始变化的大小
	progressBar->setAnchorPoint(ccp(0.5, 0)) ;
    progressBar->setPosition(ccp(winSize.width/2, margin_bottom+2));
    this->addChild(progressBar, 1) ; 
	
	return true ;
}
开发者ID:fengmm521,项目名称:qipaiproject,代码行数:58,代码来源:WelcomeView.cpp

示例14: init

bool InterfaceRenderer::init() {
    if( !CCLayer::init() )
        return false;
    
    CCSize designResolutionSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize();
    
    CCLabelTTF* label = CCLabelTTF::create("분당우리교회 청년2부 행복나무", "Arial", 100);
    label->setAnchorPoint(ccp(0.5f, 1));
    label->setPosition(ccp(designResolutionSize.width/2, designResolutionSize.height-label->getDimensions().height));
    this->addChild(label);
    
//    {
//        editbox = CCEditBox::create(CCSizeMake(800, 100), CCScale9Sprite::create("green_edit.png"));
//        editbox->retain();
//        editbox->setPosition(ccp(designResolutionSize.width/2, 10));
//        editbox->setAnchorPoint(ccp(0.5f, 0));
//        editbox->setPlaceHolder("테스트용 단어를 입력해주세요.");
//        editbox->setFont("Arial", 60);
//        editbox->setFontColor(ccBLACK);
//        this->addChild(editbox);
//    }
    
    CCMenuItemFont::setFontSize(80);
    CCMenuItemFont::setFontName("Arial");
 
    // for test button
//    {
//        CCMenuItemFont* item = CCMenuItemFont::create("Add", this, menu_selector(InterfaceRenderer::onTouchedDone));
//        item->setAnchorPoint(ccp(0, 0));
//        item->setPosition(ccp(editbox->getContentSize().width+10, 0));
//        
//        CCMenuItemFont* printItem = CCMenuItemFont::create("Print", this, menu_selector(InterfaceRenderer::onTouchedPrint));
//        printItem->setAnchorPoint(ccp(0, 0));
//        printItem->setPosition(ccp(editbox->getContentSize().width+10*2+item->boundingBox().size.width, 0));
//        
//        CCMenu* menu = CCMenu::create(item,printItem,NULL);
//        menu->setPosition(ccp(0, 0));
//        menu->setAnchorPoint(ccp(0, 0));
//        editbox->addChild(menu);
//    }
    
    
    // for menually refresh button
    {
        CCMenuItemFont* item1 = CCMenuItemFont::create("requestWord", this, menu_selector(InterfaceRenderer::onTouchedRequestWord));
        CCMenuItemFont* item2 = CCMenuItemFont::create("requestMistake", this, menu_selector(InterfaceRenderer::onTouchedRequestMistake));
        
        CCMenu* menu = CCMenu::create(item1, item2, NULL);
        menu->alignItemsVerticallyWithPadding(10);
        this->addChild(menu);
    }
    
    return true;
}
开发者ID:GoodMorningCody,项目名称:WordTree,代码行数:54,代码来源:InterfaceRenderer.cpp

示例15: init

bool CCRoomTableCell::init()
{
    this->_roomInfo = NULL;
    this->setHasRoom(false);
    
    CCLabelTTF *pLabel = CCLabelTTF::create("No Room", f_AmericanTypewriter, FONT_SIZE(kCCRoomTableCellFontSize));
    pLabel->setAnchorPoint(CCPointZero);
    this->addChild(pLabel);
    this->setLabel(pLabel);
    return this->init(NULL);
}
开发者ID:kaznog,项目名称:t09,代码行数:11,代码来源:CCRoomTableCell.cpp


注:本文中的CCLabelTTF::setAnchorPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。