本文整理汇总了C++中CCLayer::getContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayer::getContentSize方法的具体用法?C++ CCLayer::getContentSize怎么用?C++ CCLayer::getContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLayer
的用法示例。
在下文中一共展示了CCLayer::getContentSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CCSizeMake
//------------------------------------------------------------------
//
// ScrollBar2
//
//------------------------------------------------------------------
void CommonScrollBar2::onEnter()
{
CommonDemo::onEnter();
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
CCSize size = CCSizeMake(visibleSize.width * 4 / 5, visibleSize.height * 3 / 5);
CCScrollView* scroll = CCScrollView::create(size);
scroll->ignoreAnchorPointForPosition(false);
scroll->setAnchorPoint(ccp(0.5f, 0.5f));
scroll->setPosition(ccp(origin.x + visibleSize.width / 2,
origin.y + visibleSize.height / 2));
scroll->setDirection(kCCScrollViewDirectionVertical);
addChild(scroll);
CCLayer* content = createScrollContent(size);
scroll->addChild(content);
scroll->setContentSize(content->getContentSize());
scroll->setContentOffset(scroll->minContainerOffset());
// vertical bar
CCScale9Sprite* track = CCScale9Sprite::create("Images/track.png");
CCSprite* thumb = CCSprite::create("Images/thumb.png");
CCScrollBar* vsb = CCScrollBar::create(track, thumb);
vsb->setAutoFade(true);
vsb->attachToCCScrollView(scroll, cci(5, 5, 5, 5));
}
示例2: jumpPage
void GiftListView::jumpPage( int page )
{
if (page>(int)mPages.count() || page<1)
return;
for (int i=0;i<(int)mPages.count();i++)
{
CCLayer* paget = (CCLayer*)mPages.objectAtIndex(i);
float x = (i +1-page)*(paget->getContentSize().width+mPageInterval);
paget->setPositionX(x);
}
mPageCurr = page;
setPageMarkerShow(page);
}
示例3: addPage
CCLayer* GiftListView::addPage()
{
CCLayer* page = CCLayer::create();
page->setAnchorPoint(ccp(0,0));
mPages.addObject(page);
page->setContentSize(getContentSize());
float pageX=0;
if (mPageTotal!=0)
pageX = ((CCLayer*)mPages.objectAtIndex(mPageTotal-1))->getPositionX()+page->getContentSize().width + mPageInterval;
page->setPosition(ccp(pageX,0));
addChild(page);
mPageTotal++;
GiftPageMarker* marker = NULL;
if (mMarkerImgPath=="" && mMarkerDisImgPath=="")
marker = GiftPageMarker::create("spot_highlight.png","spot_dark.png");
else
marker = GiftPageMarker::create(mMarkerImgPath.c_str(),mMarkerDisImgPath.c_str());
mPageMarkers.addObject(marker);
for (int i=0;i<(int)mPageMarkers.count();i++)
{
GiftPageMarker* markertmp = (GiftPageMarker*)mPageMarkers.objectAtIndex(i);
int minterval = 7;
int mw = markertmp->mMenuItem->getContentSize().width;
int mx = i*(mw + minterval)+ getContentSize().width/2 - (mPageTotal-1)*(mw + minterval)/2 + mMarkPosOffset.x;
int my = -7 - mItemIntervalV+mMarkPosOffset.y;
markertmp->setPosition(ccp(mx,my));
}
addChild(marker);
setPageMarkerShow(1);
return page;
}
示例4: initScrollView
void SGAnnouncementLayer::initScrollView()
{
//ResourceManager::sharedInstance()->bindTexture("sgannouncementlayer/sgannouncementlayer2.plist", RES_TYPE_LAYER_UI, sg_announcementLayer);
m_scrollview->getContainer()->removeAllChildrenWithCleanup(true);
int positionY = 0;// Y轴纵向偏移,
int border_shift = 20;//内容窗口偏移
int text_wid_expand = 40;//文本区宽度扩展
if (CCEGLView::sharedOpenGLView()->getFrameSize().width == ipadResource.size.width
||CCEGLView::sharedOpenGLView()->getFrameSize().width == ipadhdResource.size.width)
{
text_wid_expand = 28;
}
//记录上一个内容窗口的底线位置
float lastWindowBorderPos = 0.0f;
for(int i = 0; i < m_arrayAnn->count(); i++)
//for (int i = 0; i < 6; i++)
{
//=======================获取数据================================
SGAnnouncementDataModel *ann = (SGAnnouncementDataModel *)m_arrayAnn->objectAtIndex(i);
CCString *title = ann->getTitle();
CCString *content = ann->getContent();
int viewId = ann->getViewId();//跳转至哪个页面
//=======================获取数据================================
CCLayer *layer = (CCLayer*)m_scrollview->getContainer();//获取scrollview的容器
CCLayerColor* contentWindow = initContentWindow(content, viewId > 0);
contentWindow->setAnchorPoint(ccp(0.5, 0));
contentWindow->ignoreAnchorPointForPosition(false);
CCSize cwSize = contentWindow->getContentSize();
CCSprite * sprite = CCSprite::createWithSpriteFrameName("Tips.png");
sprite->setScaleX(cwSize.width / 584.0);
sprite->setScaleY(cwSize.height / 522.0);
sprite->setPosition(ccp(cwSize.width * 0.5, cwSize.height * 0.5));
contentWindow->addChild(sprite, 2);
//根据上一个内容窗口的位置计算下一个窗口的位置
contentWindow->setPosition(ccp(layer->getContentSize().width * 0.5,
lastWindowBorderPos + border_shift));
/* tips.png图片拉长的倍数 */
float pngScale = cwSize.height / 522 ;
// CCLOG("*******************>>>");
// CCLOG("i = %d" , i);
// CCLOG("title = %s" , title->getCString());
// CCLOG("content = %s" , content->getCString());
// CCLOG("pos: x=%f , y = %f" , contentWindow->getPositionX() , contentWindow->getPositionY());
// CCLOG("cwSize: width=%f, height=%f", cwSize.width, cwSize.height);
// CCLOG("lastWindowBorderPos = %f" , lastWindowBorderPos);
// CCLOG("<<<********************");
lastWindowBorderPos = contentWindow->getPositionY() + cwSize.height;
//公告title
CCLabelTTF *label = CCLabelTTF::create(title->getCString(), FONT_PANGWA, 35);
label->setColor(COLOR_RED);
label->setAnchorPoint(ccp(0.5 , 1));
label->setPosition(ccp(cwSize.width *0.5f, cwSize.height - pngScale * 20));
contentWindow->addChild(label, 100);
//公告内容
// CCSize maybeTextSize = stringInLabelRect(content->getCString());
// CCLabelTTF *label_content=CCLabelTTF::create(content->getCString(), FONT_PENGYOU, 24,CCSizeMake(maybeTextSize.width + text_wid_expand * 4,maybeTextSize.height + text_hei_expand),kCCTextAlignmentLeft);
CCLabelTTF *label_content=CCLabelTTF::create(content->getCString(), FONT_PENGYOU, 24,CCSizeMake(cwSize.width - 40 * widthFactor, cwSize.height - label->getContentSize().height),kCCTextAlignmentLeft);
label_content->setAnchorPoint(ccp(0.5, 1));//内容顶线对齐
label_content->setColor(ccBLACK);
label_content->setPosition(ccp(label->getPositionX(), label->getPositionY() - label->getContentSize().height));
label_content->setZOrder(102);
contentWindow->addChild(label_content);
//点击前往按钮
if (viewId > 0) {
SGButton *goButton = SGButton::create("box_btnbg.png", NULL, this, menu_selector(SGAnnouncementLayer::AnnounceButton),CCPointZero,false,true);
CCString *go = CCString::createWithFormat(str_Hit_goto);
SGCCLabelTTF *go_label = SGCCLabelTTF::create(go->getCString(), FONT_PANGWA, 30);
goButton->addChild(go_label);
goButton->setTag(viewId);//跳转到某个视图界面
go_label->setPosition(ccp(goButton->getContentSize().width / 2, goButton->getContentSize().height / 2));
//立即前往Button
CCMenu *menu = CCMenu::create(goButton, NULL);
menu->setTouchPriority(0);
menu->setPosition(CCPointZero);
goButton->setScale(0.7);
goButton->setZOrder(200);
//goButton->setPosition(ccp(label->getPositionX(), goButton->getContentSize().height / 1.5));
goButton->setAnchorPoint(ccp(0.5, 0));
goButton->setPosition(ccp(label->getPositionX(), pngScale * 18));
menu->setZOrder(200);
contentWindow->addChild(menu);
}
layer->addChild(contentWindow);
//每次加对应的contentWindow的大小,为之后计算scrollview的内容体偏移
//.........这里部分代码省略.........
示例5: InitSprites
void RankUp::InitSprites()
{
// background
pBackground = CCSprite::create("images/splash/main_background.png");
pBackground->setAnchorPoint(ccp(0, 0));
pBackground->setPosition(ccp(0, 0));
this->addChild(pBackground, 0);
// strap
spriteClass->spriteObj.push_back( SpriteObject::Create(0, "strap_yellow.png", ccp(0, 0), ccp(14, 1506), CCSize(0, 0), "", "RankUp", this, 1) );
spriteClass->spriteObj.push_back( SpriteObject::Create(0, "strap_title_rankup.png", ccp(0.5, 0), ccp(winSize.width/2, 1552), CCSize(0, 0), "", "RankUp", this, 1) );
// pop-up 배경
spriteClass->spriteObj.push_back( SpriteObject::Create(1, "background/bg_board_brown.png", ccp(0, 0), ccp(49, 640), CCSize(982, 623), "", "RankUp", this, 1) );
spriteClass->spriteObj.push_back( SpriteObject::Create(1, "background/bg_board_yellow.png", ccp(0, 0), ccp(76, 678), CCSize(929, 562), "", "RankUp", this, 1) );
//spriteClass->spriteObj.push_back( SpriteObject::Create(0, "background/bg_popup_rightup.png", ccp(0, 0), ccp(809, 1039), CCSize(0, 0), "", "RankUp", this, 1) );
//spriteClass->spriteObj.push_back( SpriteObject::Create(0, "button/btn_x_brown.png", ccp(0, 0), ccp(900, 1132), CCSize(0, 0), "", "RankUp", this, 1) );
// 자랑하기 버튼
spriteClass->spriteObj.push_back( SpriteObject::Create(0, "button/btn_red_mini.png1", ccp(0, 0), ccp(126, 711), CCSize(0, 0), "", "RankUp", this, 5) );
spriteClass->spriteObj.push_back( SpriteObject::Create(0, "letter/letter_boast.png", ccp(0.5, 0), ccp(spriteClass->spriteObj[spriteClass->spriteObj.size()-1]->sprite->getContentSize().width/2-1, 24), CCSize(0, 0), "button/btn_red_mini.png1", "0", NULL, 5, 1) );
// 확인 버튼
spriteClass->spriteObj.push_back( SpriteObject::Create(0, "button/btn_red_mini.png2", ccp(0, 0), ccp(717+5, 711), CCSize(0, 0), "", "RankUp", this, 5) );
spriteClass->spriteObj.push_back( SpriteObject::Create(0, "letter/letter_confirm_mini.png",ccp(0.5, 0), ccp(spriteClass->spriteObj[spriteClass->spriteObj.size()-1]->sprite->getContentSize().width/2, 24), CCSize(0, 0), "button/btn_red_mini.png2", "0", NULL, 5, 1) );
// 내 순위와 점수 찾기
int myRank;
int myScore;
for (int i = 0 ; i < friendList.size() ; i++)
{
if (friendList[i]->GetKakaoId() == myInfo->GetKakaoId())
{
myScore = friendList[i]->GetWeeklyHighScore();
myRank = i+1;
break;
}
}
// 점수
char number[20];
sprintf(number, "%d", myScore);
CCLayer* pScoreLayer = Common::MakeImageNumberLayer(number, 2);
float offset = pScoreLayer->getContentSize().width/2;
pScoreLayer->setAnchorPoint(ccp(0, 0));
pScoreLayer->setPosition(ccp(winSize.width/2-offset, 840));
spriteClass->layers.push_back(pScoreLayer);
this->addChild(pScoreLayer, 6);
// 순위
sprintf(number, "%d위", myRank);
spriteClass->spriteObj.push_back( SpriteObject::CreateLabel(number, fontList[0], 48, ccp(0.5, 0.5), ccp(winSize.width/2, 970), ccc3(78,47,8), "", "RankUp", this, 5) );
// 프로필
CCLayer* profileLayer = CCLayer::create();
spriteClass->layers.push_back(profileLayer);
this->addChild(profileLayer, 6);
int height = 1100;
char name[40];
ProfileSprite* psp = ProfileSprite::GetObj(friendList[myRank]->GetImageUrl());
if (friendList[myRank]->GetImageUrl() != "" && psp->IsLoadingDone())
{
spriteClass->spriteObj.push_back( SpriteObject::CreateFromSprite(0, psp->GetProfile(), ccp(0.5, 0.5), ccp(winSize.width/2, height), CCSize(0,0), "", "Layer", profileLayer, 5, 0, 255, 1.45f*0.95f) );
sprintf(name, "background/bg_profile.png1");
spriteClass->spriteObj.push_back( SpriteObject::Create(0, name, ccp(0.5, 0.5), ccp(winSize.width/2, height), CCSize(0,0), "", "Layer", profileLayer, 6, 1) );
((CCSprite*)spriteClass->FindSpriteByName(name))->setScale(1.45f);
}
else
{
spriteClass->spriteObj.push_back( SpriteObject::CreateFromSprite(0, psp->GetProfile(), ccp(0.5, 0.5), ccp(winSize.width/2, height), CCSize(0,0), "", "Layer", profileLayer, 5, 0, 255, 1.2f) );
}
int dist = 700;
psp = ProfileSprite::GetObj(friendList[myRank-1]->GetImageUrl());
if (friendList[myRank-1]->GetImageUrl() != "" && psp->IsLoadingDone())
{
spriteClass->spriteObj.push_back( SpriteObject::CreateFromSprite(0, psp->GetProfile(), ccp(0.5, 0.5), ccp(winSize.width/2+dist, height), CCSize(0,0), "", "Layer", profileLayer, 5, 0, 255, 1.45f*0.95f) );
sprintf(name, "background/bg_profile.png2");
spriteClass->spriteObj.push_back( SpriteObject::Create(0, name, ccp(0.5, 0.5), ccp(winSize.width/2+dist, height), CCSize(0,0), "", "Layer", profileLayer, 6, 1) );
((CCSprite*)spriteClass->FindSpriteByName(name))->setScale(1.45f);
}
else
{
spriteClass->spriteObj.push_back( SpriteObject::CreateFromSprite(0, psp->GetProfile(), ccp(0.5, 0.5), ccp(winSize.width/2+dist, height), CCSize(0,0), "", "Layer", profileLayer, 5, 0, 255, 1.3f) );
}
pBlackOpen = CCSprite::create("images/ranking_scrollbg.png", CCRectMake(0, 0, winSize.width, winSize.height));
pBlackOpen->setAnchorPoint(ccp(0, 0));
pBlackOpen->setPosition(ccp(0, 0));
pBlackOpen->setColor(ccc3(0,0,0));
this->addChild(pBlackOpen, 4000);
for (int i = 0 ; i < spriteClass->spriteObj.size() ; i++)
spriteClass->AddChild(i);
/*
//.........这里部分代码省略.........