本文整理汇总了C++中CLabel::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CLabel::setPosition方法的具体用法?C++ CLabel::setPosition怎么用?C++ CLabel::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLabel
的用法示例。
在下文中一共展示了CLabel::setPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool CExpandableListViewBasicTest::init()
{
CExpandableListViewTestSceneBase::init();
setTitle("CExpandableListViewBasicTest");
setDescription("click item to expand");
pListView = CExpandableListView::create(CCSize(320, 390));
pListView->setBackgroundImage("background2.png");
pListView->setPosition(CCPoint(480, 320));
m_pWindow->addChild(pListView);
for( int i = 0; i < 10; i++ )
{
CExpandableNode* pExpandableNode = CExpandableNode::create();
pExpandableNode->setContentSize(CCSize(320, 50));
pListView->insertExpandableNodeAtLast(pExpandableNode);
CImageViewScale9* pExpandableNodeBg = CImageViewScale9::create(CCSize(320, 45), "expandnodebg.png");
pExpandableNodeBg->setPosition(CCPoint(320/2, 50/2));
pExpandableNode->addChild(pExpandableNodeBg);
CButton* pColBtn = CButton::createWith9Sprite(CCSize(35, 35), "sprite9_btn1.png", "sprite9_btn2.png");
pColBtn->setPosition(ccp(320 - 30, 50 / 2));
pColBtn->setText("-");
pColBtn->setUserTag(i);
pColBtn->setOnClickListener(this, ccw_click_selector(CExpandableListViewBasicTest::onClick));
pExpandableNode->addChild(pColBtn);
char buff[64] = {0};
sprintf(buff, "ExpandableNode : %d", i);
CLabel* pTitleLabel = CLabel::create(buff, "", 28);
pTitleLabel->setPosition(CCPoint(10, 50/2));
pTitleLabel->setAnchorPoint(CCPoint(0, 0.5));
pExpandableNode->addChild(pTitleLabel);
sprintf(buff, "Label %d - 1", i);
pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30));
sprintf(buff, "Label %d - 2", i);
pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30));
sprintf(buff, "Label %d - 3", i);
pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30));
CButton* pButton = CButton::createWith9Sprite(CCSize(150, 38), "sprite9_btn1.png", "sprite9_btn2.png");
pButton->setOnClickListener(this, ccw_click_selector(CExpandableListViewBasicTest::onClick));
pButton->initText("collapse", "", 28);
pButton->setUserTag(i);
pButton->setPosition(CCPoint(100, 40/2));
CLayout* pBtnLayout = CLayout::create(CCSize(320, 40));
pBtnLayout->addChild(pButton);
pExpandableNode->insertItemNodeAtLast(pBtnLayout);
}
pListView->reloadData();
return true;
}
示例2: onCreate
//当场景创建时调用
void CLoginScene::onCreate()
{
CWidgetLayout *bgLayer = new CWidgetLayout();
/*CCMenuItemImage *bg = CCMenuItemImage::create(s_pLoginSceneAll,"",this,NULL);
bg->setPosition(getCenterPoint());
bg->setEnabled(true);
bgLayer->addChild(bg);*/
CCSize ccSize = CCDirector::sharedDirector()->getWinSize();
CCScale9Sprite* pNickNameTextFieldBg = CCScale9Sprite::create("textfield.png");
m_pNickNameEdit = CCEditBox::create(CCSizeMake(400,70), pNickNameTextFieldBg);
m_pNickNameEdit->setPosition(ccp(530,300));
m_pNickNameEdit->setFontName("Helvetica");
m_pNickNameEdit->setFontSize(30);
m_pNickNameEdit->setFontColor(ccBLACK);
m_pNickNameEdit->setPlaceHolder("nikename:");
m_pNickNameEdit->setPlaceholderFontColor(ccRED);
m_pNickNameEdit->setMaxLength(12);
m_pNickNameEdit->setReturnType(kKeyboardReturnTypeDone);
CLabel *pLabeNickName = CLabel::create("NickName", 30);
pLabeNickName->setPosition(ccp(220, 300));
m_pExitButton = CButton::create("CloseNormal.png", "CloseSelected.png", this, menu_selector(CLoginScene::onClick));
m_pExitButton->setAnchorPoint(ccp(1,0));
m_pExitButton->setPosition(ccp(ccSize.width, 0));
m_pLoginButton = CButton::create("btn_go_0.png", "btn_go_1.png", this, menu_selector(CLoginScene::onClick));
m_pLoginButton->setPosition(620, 150);
m_pLoginButton->setString("Login");
m_pLoginButton->setFontSize(30);
bgLayer->addChild(pLabeNickName);
bgLayer->addChild(m_pExitButton);
bgLayer->addChild(m_pLoginButton);
bgLayer->addChild(m_pNickNameEdit);
this->addChild(bgLayer);
}
示例3: createLabel
CLabel* TuiManager::createLabel(float tag, const char* text, const char* font, int alignment, float fontSize, int r, int g, int b, float x, float y, float w, float h,
int r2,int g2,int b2,float strokeSize,int shadowDistance,float shadowBlur,float rotation)
{
CLabel *pLabel = CLabel::createWithTTF(text,font,fontSize);
if(shadowDistance != 0){
pLabel->setTextColor(Color4B(r,g,b,255));
pLabel->enableShadow(Color4B(r2,g2,b2,255),Size(shadowDistance,shadowDistance),shadowBlur);
}
if(strokeSize != 0){
pLabel->setTextColor(Color4B(r,g,b,255));
pLabel->enableOutline(Color4B(r2,g2,b2,255),strokeSize);
}
if(shadowDistance == 0 && strokeSize == 0){
pLabel->setColor(Color3B(r,g,b));
}
pLabel->setAlignment((TextHAlignment)alignment);
pLabel->setDimensions(w,h);
pLabel->setRotation(rotation);
pLabel->setPosition(Point(x+w/2,-(y + h/2)));
pLabel->setTag(tag);
return pLabel;
}
示例4: initLogin
void LoginLayerUC::initLogin()
{
CCLOG("LoginLayerUC::initLogin");
if(m_ui!=nullptr)
{
return;
}
//播放背景音乐
PlayBackgroundMusic(BGM_Login,true);
m_ui = LoadComponent("EnterGameUC.xaml");
m_ui->setTag(1);
m_ui->setPosition(VCENTER);
m_LayoutRoot->addChild(m_ui, 2);
//自己的登陆框隐藏
m_pLoginLay = (CLayout *)m_ui->getChildByTag(10);
m_pLoginLay->setVisible(false);
//选择好的服务器列表
m_pCurrentServerUI = (CLayout *)m_ui->findWidgetById("current_server");
m_pCurrentServerUI->setVisible(true);
//默认服务器
updateSelectServer();
//服务器选区
CLayout* pLayout = (CLayout*)m_ui->findWidgetById("serverCell");
pLayout->retain();
m_ui->removeChild(pLayout);
m_pCell = pLayout;
//获取空的滑动列表Scroll
m_pTableView = (CTableView*)m_ui->findWidgetById("serverScroll");
m_pTableView->setDirection(eScrollViewDirectionVertical);
m_pTableView->setSizeOfCell(m_pCell->getContentSize());
m_pTableView->setCountOfCell(m_serverInfo.server_list().size());
m_pTableView->setBounceable(true);
m_pTableView->setDataSourceAdapter(this, ccw_datasource_adapter_selector(LoginLayerUC::tableviewDataSource));
m_pTableView->reloadData();
//按钮打开服务器列表
CImageView* pBtnServer = (CImageView*)m_ui->findWidgetById("serverBtn");
//快速登录按钮
CButton * pQuickLogin = (CButton *)m_ui->getChildByTag(1);
pQuickLogin->setOnClickListener(this,ccw_click_selector(LoginLayerUC::onQuickLogin));
CCActionInterval *scaleSmall = CCScaleTo::create(0.9f,0.98f);
CCFadeTo *out = CCFadeTo::create(0.9f,60);
CCSpawn *spawn = CCSpawn::createWithTwoActions(scaleSmall,out);
CCActionInterval *scaleBig = CCScaleTo::create(1.2f,1.0f);
CCFadeTo *in = CCFadeTo::create(1.2f,255);
CCSpawn *spawn1 = CCSpawn::createWithTwoActions(scaleBig,in);
CCSequence *seque = CCSequence::createWithTwoActions(spawn,spawn1);
CCRepeatForever *action = CCRepeatForever::create(seque);
pQuickLogin->runAction(action);
pQuickLogin->setVisible(true);
//清除用户信息
DataCenter::sharedData()->getUser()->clear();
//版本做相对位置处理
CLabel* pLabel = (CLabel *)m_ui->findWidgetById("version");
pLabel->setAnchorPoint(ccp(1.0f, 0.0f));
pLabel->setPosition(ccp(VRIGHT-20, VBOTTOM+20));
CC_SAFE_RETAIN(pLabel);
pLabel->removeFromParentAndCleanup(true);
this->addChild(pLabel);
CC_SAFE_RELEASE(pLabel);
pLabel->setString(CCString::createWithFormat("Version:%s", m_serverInfo.game_version().c_str())->getCString());
//隐藏服务器列表
showServerList();
hideServerList();
//TODO
//初始化UC_SDK?-放在最前面
//还是点击登录再初始化?
//点击登录再初始化吧
//初始化完直接请求登录
//先连接连接服务器
const Server& gameServer = m_serverInfo.server_list().Get(m_iSelectServerIndex);
//检查服务器是否可用
if(!checkServerStatus(gameServer))
{
return;
}
LinkedGameServer(gameServer);
}