本文整理汇总了C++中CButton::getContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CButton::getContentSize方法的具体用法?C++ CButton::getContentSize怎么用?C++ CButton::getContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CButton
的用法示例。
在下文中一共展示了CButton::getContentSize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onSelectCity
void CCommandLayer::onSelectCity(CCObject* pSender)
{
CButton *btn = (CButton*)pSender;
// m_selectCellImg->setPosition(btn->getParent()->convertToWorldSpace(btn->getPosition()));
m_selectCellImg->removeFromParent();
btn->addChild(m_selectCellImg);
m_selectCellImg->setVisible(true);
m_selectCellImg->setPosition(ccp(btn->getContentSize().width/2,btn->getContentSize().height/2));
m_selectCity = (CCity*)btn->getUserData();
updateSelectCity(m_selectCity);
}
示例2: updateHero
void CCommandLayer::updateHero(const TMessage& tMsg)
{
//清空
if (tMsg.nMsg ==0)
{
CButton *btn = (CButton*)(m_garrsionLayer->getChildByTag(m_selectHero));
btn->removeChildByTag(1);
CHero hero;
hero.id= 0;
// memset((void*)&hero,0,sizeof(CHero));
m_city.heroList[m_selectHero-1] = hero;
//
CCNode *lab = (CCNode*)m_garrsionLayer->findWidgetById(CCString::createWithFormat("lab%d",m_selectHero)->getCString());
lab->setVisible(true);
}
else
{
CButton *btn = (CButton*)(m_garrsionLayer->getChildByTag(m_selectHero));
CHero *hero = (CHero*)tMsg.lParam;
string icon = ToString(hero->thumb);
btn->removeChildByTag(1);
CCNode *lab = (CCNode*)m_garrsionLayer->findWidgetById(CCString::createWithFormat("lab%d",m_selectHero)->getCString());
lab->setVisible(false);
CCSprite *head = CCSprite::create(CCString::createWithFormat("headImg/%d.png",hero->thumb)->getCString());
if (!head)
{
head = CCSprite::create("headImg/101.png");
CCLOG("[ ERROR ] CCommandLayer::updateHero Lost Image = %d",hero->thumb);
}
head->setPosition(ccp(btn->getContentSize().width/2, btn->getContentSize().height/2));
head->setTag(1);
head->setScale(82.0f/100.0f);
btn->addChild(head);
btn->setEnabled(false);
head->setColor(RGB_GRAY_COLOR);
if (m_selectHero>m_city.heroList.size())
{
m_city.heroList.push_back(*hero);
}
else
{
m_city.heroList[m_selectHero-1] = *hero;
}
delete hero;
}
}
示例3: init
bool ViewScene::init(string unitid, string ziid, string curChar){
CCLog("ViewScene init");
if (!CCLayerColor::initWithColor(ccc4(255,255,255,255)))
{
return false;
}
this->unit_id = unitid;
this->zi_id = ziid;
this->currentChar = curChar;
Notes = SQLiteData::getNote(unit_id,zi_id);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCSize visiableSize = CCDirector::sharedDirector()->getVisibleSize();
CCSprite* titlebar = CCSprite::create("strangedesign/title bar_background.png");
addChild(titlebar);
titlebar->setPosition(ccp(visiableSize.width/2,visiableSize.height-titlebar->getContentSize().height/2));
CWidgetWindow* m_pWindow = CWidgetWindow::create();
m_pWindow->setMultiTouchEnabled(true);
addChild(m_pWindow);
CButton* backBtn = CButton::create("strangedesign/back_button.png", "strangedesign/back_button_down.png");
backBtn->setOnClickListener(this,ccw_click_selector(ViewScene::back));
backBtn->setPosition(ccp(backBtn->getContentSize().width/2+10, visiableSize.height -backBtn->getContentSize().height/2-50));
m_pWindow->addChild(backBtn);
CButton* deleteBtn = CButton::create("strangedesign/Free_writting_delete_button_up.png","strangedesign/Free_writting_delete_button_down.png");
deleteBtn->setOnClickListener(this, ccw_click_selector(ViewScene::deleteBtnClick));
deleteBtn->setPosition(ccp(winSize.width-deleteBtn->getContentSize().width/2, winSize.height-deleteBtn->getContentSize().height/2));
m_pWindow->addChild(deleteBtn);
CCSize visualSize = CCSizeMake(winSize.width,winSize.height-titlebar->getContentSize().height-10);
CCSize gridcellSize = CCSizeMake(360 , 350);
writingCount = Notes.size();
pGridView = CGridView::create(visualSize,
gridcellSize,
writingCount,
this,
ccw_datasource_adapter_selector(ViewScene::gridViewDataSource));
pGridView->setColumns(2);
pGridView->setPosition(CCSize(winSize.width/2,(winSize.height-titlebar->getContentSize().height)/2));
pGridView->setAutoRelocate(true);
pGridView->reloadData();
m_pWindow->addChild(pGridView);
return true;
}
示例4: showBuildInfo
void CCommandLayer::showBuildInfo(const CCity& ct)
{
int i=0;
for (; i<ct.heroList.size()&&i<3; i++)
{
CButton *btn = (CButton*)(m_garrsionLayer->getChildByTag(i+1));
const CHero &hero = ct.heroList[i];
if (hero.thumb!=0)
{
CCSprite *head = CCSprite::create(CCString::createWithFormat("headImg/%d.png",hero.thumb)->getCString());
if (!head)
{
head = CCSprite::create("headImg/101.png");
CCLOG("[ ERROR ] CCommandLayer::showBuildInfo Lost Image = %d",hero.thumb);
}
head->setPosition(ccp(btn->getContentSize().width/2, btn->getContentSize().height/2));
head->setTag(1);
head->setScale(82.0f/100.0f);
btn->addChild(head);
if (!hero.remove)
{
btn->setEnabled(false);
head->setColor(RGB_GRAY_COLOR);
}
}
CCNode *lab = (CCNode*)m_garrsionLayer->findWidgetById(CCString::createWithFormat("lab%d",i+1)->getCString());
lab->setVisible(false);
}
for (i=ct.heroNum;i<3;i++)
{
CButton *btn = (CButton*)(m_garrsionLayer->getChildByTag(i+1));
btn->setEnabled(false);
CCNode *lab = (CCNode*)m_garrsionLayer->findWidgetById(CCString::createWithFormat("lab%d",i+1)->getCString());
lab->setVisible(false);
}
//runFadeAction(ct);
}
示例5: gridViewDataSource
CCObject* ViewScene::gridViewDataSource(CCObject* pContentView, unsigned int idx){
CGridViewCell* pCell = (CGridViewCell*) pContentView;
CButton* pButton = NULL;
CCheckBox* pCheckbox = NULL;
Notes = SQLiteData::getNote(unit_id,zi_id);
vector<string> oneNote = Notes.at(idx); //oneNote 中第一个元素为ID,第二个元素为笔画序列
if (!pCell)
{
pCell = new CGridViewCell();
pCell->autorelease();
pButton = CButton::create("strangedesign/Dlg_cancel_button.png","strangedesign/Dlg_cancel_button_down.png");
pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2));
pCheckbox = CCheckBox::create();
pCheckbox->setNormalImage("ckb_normal_01.png");
pCheckbox->setNormalPressImage("ckb_normal_02.png");
pCheckbox->setCheckedImage("ckb_selected_01.png");
pCheckbox->setCheckedPressImage("ckb_selected_02.png");
pCheckbox->setDisabledNormalImage("ckb_disable_01.png");
pCheckbox->setDisabledCheckedImage("ckb_disable_02.png");
pCheckbox->setPosition(CCPoint(360-pCheckbox->getContentSize().width, 350-pButton->getContentSize().height/2));
pCell->addChild(pCheckbox,10);
//pCell->addChild(pButton,10);
HcharacterDrawnode* handwritingHz = HcharacterDrawnode::create();
vector< vector<CCPoint> > strokesvec = DataTool::spliteString(oneNote.at(1));
for (unsigned int i = 0; i < strokesvec.size(); i++)
{
vector<CCPoint> oneStrokeVec = strokesvec[i];
Stroke stroke(oneStrokeVec);
handwritingHz->addStroke(stroke);
}
handwritingHz->setContentSize(CCSize(320,320));
CCPoint position = ccp(360/2- handwritingHz->getContentSize().width/2, 350/2- handwritingHz->getContentSize().height/2);
handwritingHz->setPosition(position);
pCell->addChild(handwritingHz,1);
}else
{
pButton = CButton::create("strangedesign/Dlg_cancel_button.png","strangedesign/Dlg_cancel_button_down.png");
pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2));
pCheckbox = CCheckBox::create();
pCheckbox->setNormalImage("ckb_normal_01.png");
pCheckbox->setNormalPressImage("ckb_normal_02.png");
pCheckbox->setCheckedImage("ckb_selected_01.png");
pCheckbox->setCheckedPressImage("ckb_selected_02.png");
pCheckbox->setDisabledNormalImage("ckb_disable_01.png");
pCheckbox->setDisabledCheckedImage("ckb_disable_02.png");
pCheckbox->setPosition(CCPoint(360-pCheckbox->getContentSize().width, 350-pButton->getContentSize().height/2));
pCell->addChild(pCheckbox,10);
//pCell->addChild(pButton,10);
HcharacterDrawnode* handwritingHz = HcharacterDrawnode::create();
vector<string> oneNote = Notes.at(idx); //oneNote 中第一个元素为ID,第二个元素为笔画序列
vector< vector<CCPoint> > strokesvec = DataTool::spliteString(oneNote.at(1));
for (unsigned int i = 0; i < strokesvec.size(); i++)
{
vector<CCPoint> oneStrokeVec = strokesvec[i];
Stroke stroke(oneStrokeVec);
handwritingHz->addStroke(stroke);
}
handwritingHz->setContentSize(CCSize(320,320));
CCPoint position = ccp(360/2- handwritingHz->getContentSize().width/2, 350/2- handwritingHz->getContentSize().height/2);
handwritingHz->setPosition(position);
pCell->addChild(handwritingHz,1);
}
char buff[64];
sprintf(buff, "%u", idx);
pButton->getLabel()->setString(buff);
int userTag = DataTool::stringToInt(oneNote.at(0));
pButton->setUserTag(userTag);
pCheckbox->setUserTag(userTag);
pButton->setOnClickListener(this,ccw_click_selector(ViewScene::buttonClick));
pCheckbox->setOnClickListener(this,ccw_click_selector(ViewScene::checkBoxClick));
return pCell;
}
示例6: showSmeltDataToUI
void CSmeltArmor::showSmeltDataToUI()
{
const ItemData * itemData = DataCenter::sharedData()->getItemDesc()->getCfg(m_armor.itemId);
//贴图
CCSprite *prop = getItemSprite(&m_armor);
if (!prop)
{
prop = CImageView::create("prop/32003.png");
}
//选择按钮
CButton *btn = dynamic_cast<CButton*>(m_ui->findWidgetById("select"));
btn->removeChildByTag(1);
prop->setPosition(ccp(btn->getContentSize().width/2,btn->getContentSize().height/2));
prop->setTag(1);
btn->addChild(prop, -1);
((CCSprite*)btn->getNormalImage())->setTexture(setItemQualityTexture(m_armor.quality));
//添加星星层
btn->removeChildByTag(415);
CLayout* pStarLayout = getStarLayout(m_armor.iStar);
btn->addChild(pStarLayout, 415, 415);
//更新名字
CLabel *name = dynamic_cast<CLabel*>(m_ui->findWidgetById("name"));
CCString *str = CCString::create("XXX");
if(itemData)
{
str = CCString::createWithFormat("%s",itemData->itemName.c_str());
}
name->setString(str->getCString());
name->setVisible(true);
//加号
CCSprite *why = dynamic_cast<CCSprite*>(m_ui->findWidgetById("why"));
why->setVisible(false);
//设置等级
CLabel* pLevel = dynamic_cast<CLabel*>(m_ui->findWidgetById("level"));
CCNode* pLevelBg = dynamic_cast<CCNode*>(m_ui->findWidgetById("level_mask"));
if(m_armor.itemLevel>0)
{
pLevel->setVisible(true);
pLevelBg->setVisible(true);
pLevel->setString(CCString::createWithFormat("+%d", m_armor.itemLevel)->getCString());
}
else
{
pLevel->setVisible(false);
pLevelBg->setVisible(false);
}
m_attr->setVisible(true);
//显示背景框等等
CCNode* pNode4 = (CCNode*)m_ui->findWidgetById("tip");
pNode4->setVisible(false);
m_pSpineHero->setVisible(false);
initSpandAndCheckBox();
showArmorAttr();
//更新钱
onCheckAttr(nullptr, false);
//设置动作
showMoveAction("box_bg");
showMoveAction("select");
showMoveAction("why");
showMoveAction("level");
showMoveAction("level_mask");
}
示例7: gridviewDataSource
CCObject* MainScene::gridviewDataSource(CCObject* pConvertView, unsigned int idx){
CGridViewCell* pCell = (CGridViewCell*) pConvertView;
CButton* pButton = NULL;
CCLog("idx %d",idx);
if(!pCell)
{
pCell = new CGridViewCell();
pCell->autorelease();
pButton = CButton::create("strangedesign/main_clincher.png","strangedesign/main_clincher_down.png");
pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2));
pButton->getLabel()->setFontSize(40.0f);
pButton->setTag(1);
pCell->addChild(pButton,10);
CCSprite* sprite = CCSprite::create("strangedesign/table4mul4.png");
sprite->setContentSize(CCSize(320,320));
sprite->setPosition(CCPoint(360/2,350/2));
pCell->addChild(sprite,1);
CCLog("idx %d",idx);
vector<vector<string> > groupCharacter = SQLiteData::getUnit(unit_ids.at(idx));
CCPoint positions[16] = {ccp(40,280),ccp(120,280),ccp(200,280),ccp(280,280),
ccp(40,200),ccp(120,200),ccp(200,200),ccp(280,200),
ccp(40,120),ccp(120,120),ccp(200,120),ccp(280,120),
ccp(40,40),ccp(120,40),ccp(200,40),ccp(280,40)
};
for (unsigned int i = 0; i < groupCharacter.size(); i++)
{
string hanzi = groupCharacter.at(i).at(0);
CCLabelTTF* clabel = CCLabelTTF::create(hanzi.c_str(),"Arial",40);
clabel->setPosition(positions[i]);
clabel->setColor(ccc3(0,0,0));
sprite->addChild(clabel);
}
}
else
{
pButton = CButton::create("strangedesign/main_clincher.png","strangedesign/main_clincher_down.png");
pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2));
pButton->getLabel()->setFontSize(40.0f);
pButton->setTag(1);
pCell->addChild(pButton,10);
CCSprite* sprite = CCSprite::create("strangedesign/table4mul4.png");
sprite->setContentSize(CCSize(320,320));
sprite->setPosition(CCPoint(360/2,350/2));
pCell->addChild(sprite,1);
CCLog("idx %d",idx);
vector<vector<string> > groupCharacter = SQLiteData::getUnit(unit_ids.at(idx));
CCPoint positions[16] = {ccp(40,280),ccp(120,280),ccp(200,280),ccp(280,280),
ccp(40,200),ccp(120,200),ccp(200,200),ccp(280,200),
ccp(40,120),ccp(120,120),ccp(200,120),ccp(280,120),
ccp(40,40),ccp(120,40),ccp(200,40),ccp(280,40)
};
for (unsigned int i = 0; i < groupCharacter.size(); i++)
{
string hanzi = groupCharacter.at(i).at(0);
CCLabelTTF* clabel = CCLabelTTF::create(hanzi.c_str(),"Arial",40);
clabel->setPosition(positions[i]);
clabel->setColor(ccc3(0,0,0));
sprite->addChild(clabel);
}
}
char buff[64];
unsigned int labelidx = idx+1;
sprintf(buff, "%u", labelidx);
pButton->getLabel()->setString(buff);
pButton->setUserTag(idx);
pButton->setOnClickListener(this,ccw_click_selector(MainScene::buttonClick));
pButton->setOnLongClickListener(this,ccw_longclick_selector(MainScene::buttonLongClick));
return pCell;
}