本文整理汇总了C++中CCMenuItemSprite::setContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCMenuItemSprite::setContentSize方法的具体用法?C++ CCMenuItemSprite::setContentSize怎么用?C++ CCMenuItemSprite::setContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCMenuItemSprite
的用法示例。
在下文中一共展示了CCMenuItemSprite::setContentSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setDimensions
// on "init" you need to initialize your instance
bool S11PrepareRes::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
//每个项目都要创建的东西
_menu = CCMenu::create(NULL);
_menu->setPosition(CCPointZero);
this->addChild(_menu, 101);
titleString = "";
scriptMap=ScriptParser::paserScript("S11PrepareRes","leftTitle");//right_TableView_Map
//背景图
{
CCSprite * aSprite = CCSprite::create("s11Background.png");
aSprite->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
//CC_BREAK_IF(! aSprite);
this->addChild(aSprite,98);
aSprite ->getTexture()->setAntiAliasTexParameters();//抗锯齿
}
//控件
{
CCSprite * aSprite = CCSprite::create("s11NavBar.png");
aSprite->setAnchorPoint(ccp(0.0,1.0));
aSprite->setPosition(ccp(0,visibleSize.height-40));
this->addChild(aSprite,100);
}
{
CCLabelTTF * leftTitleLabel = CCLabelTTF::create(s11Str2_macro,s11FontName_macro,s11TitleFontSize_macro);
CCLabelTTF* pLabel = leftTitleLabel;
pLabel->setColor(ccWHITE);
pLabel->setPosition( s11Position3_macro(pLabel));
this->addChild(pLabel, 100);
}
titleLabel = CCLabelTTF::create(s11Str2_macro,s11FontName_macro,s11TitleFontSize_macro);
CCLabelTTF* pLabel = titleLabel;
pLabel->setColor(ccWHITE);
pLabel->setPosition( s11Position4_macro(pLabel));
this->addChild(pLabel, 100);
{
CCSprite * aSprite = CCSprite::create("pRecButton.png");
aSprite->setPosition(s11Position1_macro(aSprite));
this->addChild(aSprite,100);
CCSprite * aSprite1 = CCSprite::create("s11FullScreenIcon.png");
aSprite1->setPosition(s11Position1_macro(aItem));
this->addChild(aSprite1,100);
CCSprite * sprite1 = CCSprite::create();
CCSprite * sprite2 = CCSprite::create();
CCMenuItemSprite *aItem = CCMenuItemSprite::create(
sprite1,
sprite2,
this,
menu_selector(S11PrepareRes::menuCloseCallback));
aItem->setPosition(s11Position1_macro(aItem));
aItem->setContentSize(aSprite->getContentSize());
_menu ->addChild(aItem,100);
}
CCTableView * tableView = CCTableView::create(this, s11Size1_macro);
tableView->setAnchorPoint(ccp(0.0,0.0));
tableView->setDirection(kCCScrollViewDirectionVertical);
tableView->setPosition(s11Position8_macro(tableView));
tableView->setDelegate(this);
tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
this->addChild(tableView,99);
tableView->reloadData();
std::string aStr = ScriptParser::readScript("s11TableCellTxt1.txt");
S11PrepareRes::detailString = aStr;
rightDetailTex = CCLabelTTF::create(aStr.c_str(), "Helvetica", 30.0);
rightDetailTex->setColor(ccBLACK);
rightDetailTex-> setDimensions(s11Size2_macro);
rightDetailTex->setPosition(s11Position9_macro(label));
this->addChild(rightDetailTex,100);
//TabelBar
//.........这里部分代码省略.........
示例2: ccp
bool S4HeZuo::setUpSubClass()
{
bool bRet = false;
do
{
float firstStrFontSize = ScriptParser::getFontSizeFromPlist(plistDic,"firstTitle");
CCLabelTTF *firstTitleLabel = CCLabelTTF::create(ScriptParser::getStringFromPlist(plistDic,"firstTitle"), s1FontName_macro, firstStrFontSize);
firstTitleLabel->setColor(ccc3(193.0,159.0,113.0));
firstTitleLabel->setPosition(ScriptParser::getPositionFromPlist(plistDic,"firstTitle"));
this->addChild(firstTitleLabel,zNum+1);
CCSprite * S1PSubBottomSprite = CCSprite::create("S1PSubBottom.png");
S1PSubBottomSprite->setPosition( ccp(origin.x+visibleSize.width/2,firstTitleLabel->getPosition().y-firstTitleLabel->getContentSize().height/2-10));
this->addChild(S1PSubBottomSprite,zNum);
map<string, string> naviGroupStrMap = ScriptParser::getGroupStringFromPlist(plistDic,"naviTitle");
float naviFontSize = ScriptParser::getFontSizeFromPlist(plistDic,"naviTitle");
CCPoint naviStrPosition = ScriptParser::getPositionFromPlist(plistDic,"naviTitle");
for (int i=0; i<(int)naviGroupStrMap.size(); i++)
{
const char * labelStr = naviGroupStrMap[PersonalApi::convertIntToString(i+1)].c_str();
CCLabelTTF *pLabel = CCLabelTTF::create(labelStr, s1FontName_macro, naviFontSize);
pLabel->setPosition(ccp(naviStrPosition.x+(pLabel->getContentSize().width+20)*i,naviStrPosition.y));
pLabel->setColor(ccc3(128.0,128.0,128.0));
this->addChild(pLabel,zNum+1);
if ( AppDelegate::S4SelectNavi == i+1)
{
pLabel->setColor(ccc3(255.0,255.0,255.0));
CCSprite * selectFrameSprite = CCSprite::create("PSubNavBackground.png");
selectFrameSprite->setScaleX(pLabel->getContentSize().width/selectFrameSprite->getContentSize().width);
selectFrameSprite ->setPosition(pLabel->getPosition());
this->addChild(selectFrameSprite,zNum);
}
CCSprite * sprite1 = CCSprite::create();
CCSprite * sprite2 = CCSprite::create();
CCMenuItemSprite *aItem = CCMenuItemSprite::create(
sprite1,
sprite2,
this,
menu_selector(S4HeZuo::menuCallback));
CC_BREAK_IF(! aItem);
aItem->setPosition(pLabel->getPosition());
aItem->setContentSize(pLabel->getContentSize());
aItem->setTag(btnTag+i+1);
_menu ->addChild(aItem,zNum);
}
CC_BREAK_IF(! setUpSubClass2());
bRet = true;
} while (0);
return bRet;
}
示例3: CCRectMake
bool S411FeedBack::setUpSubClass2()
{
bool bRet = false;
do
{
refreshItemImage->setOpacity(0);
refreshItemImage->setEnabled(false);
isMale = true;
AppDelegate::S51TextViewStr = "";
feedBackSp = CCSprite::create("S41FeedBack.png");
feedBackSp->setPosition(ccp(530,330));
this->addChild(feedBackSp, zNum, 10);
float pox = 487;
float poy = 477;
male = CCSprite::create("S49RadioSelected.png");
male->setPosition(ccp(pox,poy));
this->addChild(male,zNum);
CCSprite * sprite1 = CCSprite::create();
CCSprite * sprite2 = CCSprite::create();
CCMenuItemSprite * maleItem = CCMenuItemSprite::create(
sprite1,
sprite2,
this,
menu_selector(S411FeedBack::changeSex));
maleItem->setPosition(male->getPosition());
maleItem->setContentSize(CCSizeMake(male->getContentSize().width*3, male->getContentSize().height*3));
_menu->addChild(maleItem,zNum);
famale =CCSprite::create("S49RadioSelected.png");
famale->setPosition(ccp(pox+45,poy));
this->addChild(famale,zNum);
famale->setOpacity(0);
CCSprite * sprite3 = CCSprite::create();
CCSprite * sprite4 = CCSprite::create();
CCMenuItemSprite * faMaleItem = CCMenuItemSprite::create(sprite3, sprite4,this,menu_selector(S411FeedBack::changeSex));
faMaleItem->setPosition(famale->getPosition());
faMaleItem->setContentSize(CCSizeMake(famale->getContentSize().width*3, famale->getContentSize().height*3));
_menu->addChild(faMaleItem,zNum);
float editFontSize = 10;
float addWidth = 128.0;
float addHeight = 45;
const char * input = "";
CCScale9Sprite *sacel9SprG1=CCScale9Sprite::create("S49Submit.png");
sacel9SprG1->setOpacity(1);
nameBox=CCEditBox::create(CCSizeMake(sacel9SprG1->getContentSize().width*2.8, sacel9SprG1->getContentSize().height), sacel9SprG1);
nameBox->setFontName(s1FontName_macro);
nameBox->setFontSize(editFontSize);
nameBox->setFontColor(ccBLACK);
nameBox->setInputMode(kEditBoxInputModeAny);
nameBox->setPlaceHolder(input);
nameBox->setPosition(ccp(240+addWidth,430+addHeight));
this->addChild(nameBox,zNum);
nameBox->setDelegate(this);
CCScale9Sprite *sacel9SprG2=CCScale9Sprite::create("S49Submit.png");
sacel9SprG2->setOpacity(1);
telBox=CCEditBox::create(CCSizeMake(sacel9SprG2->getContentSize().width*2.8, sacel9SprG2->getContentSize().height), sacel9SprG2);
telBox->setFontSize(editFontSize);
telBox->setFontColor(ccBLACK);
telBox->setPlaceHolder(input);
telBox->setPosition(ccp(240+addWidth,400+addHeight));
this->addChild(telBox,zNum);
telBox->setDelegate(this);
CCScale9Sprite *sacel9SprG3=CCScale9Sprite::create("S49Submit.png");
sacel9SprG3->setOpacity(1);
mobilePhoneBox=CCEditBox::create(CCSizeMake(sacel9SprG3->getContentSize().width*2.8, sacel9SprG3->getContentSize().height), sacel9SprG3);
mobilePhoneBox->setFontSize(editFontSize);
mobilePhoneBox->setFontColor(ccBLACK);
mobilePhoneBox->setPlaceHolder(input);
mobilePhoneBox->setPosition(ccp(240+addWidth,365+addHeight));
this->addChild(mobilePhoneBox,zNum);
mobilePhoneBox->setDelegate(this);
CCScale9Sprite *sacel9SprG4=CCScale9Sprite::create("S49Submit.png");
sacel9SprG4->setOpacity(1);
mailBox=CCEditBox::create(CCSizeMake(sacel9SprG4->getContentSize().width*2.8, sacel9SprG4->getContentSize().height), sacel9SprG4);
mailBox->setFontSize(editFontSize);
mailBox->setFontColor(ccBLACK);
mailBox->setPlaceHolder(input);
mailBox->setPosition(ccp(240+addWidth,335+addHeight));
this->addChild(mailBox,zNum);
mailBox->setDelegate(this);
//.........这里部分代码省略.........
示例4: CCSizeMake
bool S132Detail::setUpSubClass2()
{
bool bRet = false;
do
{
/*
float titleFontSize = ScriptParser::getFontSizeFromPlist(plistDic,"title");
const char * titleLabelStr = ScriptParser::getStringFromPlist(plistDic,"title");
CCLabelTTF *titleLabel = CCLabelTTF::create(titleLabelStr, s1FontName_macro, titleFontSize);
titleLabel->setAnchorPoint(ccp(0.0,1.0));
titleLabel->setPosition(ScriptParser::getPositionFromPlist(plistDic,"title"));
titleLabel->setColor(ccBLACK);
this->addChild(titleLabel,zNum);
*/
{
CCSprite * aSprite = CCSprite::create("PBackBtn.png");
aSprite->setPosition( ScriptParser::getPositionFromPlist(plistDic,"PBackBtn"));
this->addChild(aSprite,zNum);
CCSprite * sprite1 = CCSprite::create();
CCSprite * sprite2 = CCSprite::create();
CCMenuItemSprite *aItem = CCMenuItemSprite::create(
sprite1,
sprite2,
this,
menu_selector(S132Detail::moreMenuCallback));
aItem->setPosition(aSprite->getPosition());
aItem->setContentSize(aSprite->getContentSize());
aItem->setTag(btnTag);
_menu ->addChild(aItem,zNum);
}
/*
CCSprite * showbigPicture = CCSprite::create("s133LeftBigImg.png");
showbigPicture->setPosition( ScriptParser::getPositionFromPlist(plistDic,"s133LeftBigImg"));
this->addChild(showbigPicture,zNum);
CCTextureCache::sharedTextureCache()->removeAllTextures();
float detailFontSize1 = ScriptParser::getFontSizeFromPlist(plistDic,"detailStr");
CCSize detailDimensionsSize1 = ScriptParser::getSizeFromPlist(plistDic,"detailStr1");
const char * detailLabelStr1 = ScriptParser::getStringFromPlist(plistDic,"detailStr1");
CCLabelTTF *detailLabel1 = CCLabelTTF::create(detailLabelStr1, s1FontName_macro, detailFontSize1, detailDimensionsSize1, kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
detailLabel1->setAnchorPoint(ccp(0.0,1.0));
detailLabel1->setPosition(ScriptParser::getPositionFromPlist(plistDic,"detailStr1"));
detailLabel1->setColor(ccBLACK);
this->addChild(detailLabel1,zNum);
float detailFontSize2 = ScriptParser::getFontSizeFromPlist(plistDic,"detailStr");
CCSize detailDimensionsSize2 = ScriptParser::getSizeFromPlist(plistDic,"detailStr2");
const char * detailLabelStr2 = ScriptParser::getStringFromPlist(plistDic,"detailStr2");
CCLabelTTF *detailLabel2 = CCLabelTTF::create(detailLabelStr2, s1FontName_macro, detailFontSize2, detailDimensionsSize2, kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
detailLabel2->setAnchorPoint(ccp(0.0,1.0));
detailLabel2->setPosition(ScriptParser::getPositionFromPlist(plistDic,"detailStr2"));
detailLabel2->setColor(ccBLACK);
this->addChild(detailLabel2,zNum);
*/
//showbigPicture->setPosition( ScriptParser::getPositionFromPlist(plistDic,"S133TuWen"));
//this->addChild(showbigPicture,zNum);
m_pScrollView = CCScrollView::create();
string imageName = "S133TuWen"+PersonalApi::convertIntToString(AppDelegate::S1NewsSelected)+".png";
imageName = PersonalApi::getRealImageName(imageName.c_str(),"S321ScrollPic.png");
CCSprite * showbigPicture;
if (imageName.compare("S321ScrollPic.png") != 0)
{
showbigPicture = CCSprite::create(imageName.c_str());
}
else
{
showbigPicture = CCSprite::create();
}
showbigPicture->setPosition(CCPointZero);
m_pScrollView->addChild(showbigPicture,zNum);
scrollMaxSizeX = showbigPicture->getContentSize().width;
scrollMaxSizeY = showbigPicture->getContentSize().height;
m_pScrollView->setPosition(ccp(30,100)); //¡¯?¡°a¡Ü¦¸??1.0¡Þ¨º¡À?¡Ìa¡±¨C¦Ì?¡ê¡§¡Â?¡°?¡ê¡ã
CCSize showSize = CCSizeMake(showbigPicture->getContentSize().width, 450);
m_pScrollView->setContentOffset(ccp(0,-(showbigPicture->getContentSize().height-showSize.height)));
//.........这里部分代码省略.........