本文整理汇总了C++中CCLayer::setContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayer::setContentSize方法的具体用法?C++ CCLayer::setContentSize怎么用?C++ CCLayer::setContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLayer
的用法示例。
在下文中一共展示了CCLayer::setContentSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateLayerMessageBox
void AssetsUpdateLayer::updateLayerMessageBox()
{
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("ccb/ccbResources/SystemLoading.plist");
CCLayer* layer = CCLayer::create();
layer->ignoreAnchorPointForPosition(false);
layer->setContentSize(Size(960, 640));
layer->setPosition(Point(Director::getInstance()->getWinSize().width * 0.5, Director::getInstance()->getWinSize().height * 0.5));
layer->setScale(Director::getInstance()->getWinSize().width / 960);
addChild(layer, 1);
Sprite* messageboxSprite = Sprite::createWithSpriteFrameName("set_floor_v1.png");
messageboxSprite->setPosition(Point(480, 320));
layer->addChild(messageboxSprite, 1);
LabelTTF* labelContent = LabelTTF::create(Localization::getInstance()->getValueByKey("Loading_warning_need_update"), "Helvetica",32);
labelContent->setPosition(Point(480, 420));
layer->addChild(labelContent, 1);
ControlButton* btn = ControlButton::create(LabelTTF::create(Localization::getInstance()->getValueByKey("BUTTON_DONE"), "Helvetica", 32), Scale9Sprite::createWithSpriteFrameName("set_button2.png"));
btn->setPreferredSize(CCSize(191,70));
btn->setPosition(Point(480, 220));
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(AssetsUpdateLayer::GoToAppPage), Control::EventType::TOUCH_UP_INSIDE);
layer->addChild(btn, 1);
}
示例2: init
bool GuideScene::init()
{
if (!CCLayer::init()) {
return false;
}
CCLOG("/**~~~~~~~~~~~~~~~~GuideScene:init()~~~~~~~~~~~~~~~~~");
//取出主屏幕的尺寸,以及初始化数据
size = CCDirector::sharedDirector()->getVisibleSize();
// CCSprite* whiteBg = CCSprite::create("ZF_Shoot_whiteBg.png",CCRectMake(0,0,size.width,size.height));
// whiteBg->setPosition(ccp(size.width*0.5,size.height*0.5));
// whiteBg->setContentSize(size);
// this->addChild(whiteBg,0);
CCSprite* helpBg = CCSprite::create("ZF_Shoot_help.png");
helpBg->setAnchorPoint(ccp(0.5,0.5));
helpBg->setPosition(ccp(size.width*0.5,size.height*0.5));
this->addChild(helpBg,0);
//1.create a container
CCLayer* container = CCLayer::create();
CCSprite* guide = CCSprite::create("ZF_Shoot_guide.png");
guide->setAnchorPoint(ccp(0.5,1));
guide->setPosition(ccp(size.width*0.5,size.height));
container->addChild(guide,1);
container->setContentSize(size);
//2.create a scrollView
CCScrollView* scrollView = CCScrollView::create(CCSizeMake(size.width*0.5, size.height*3));
addChild(scrollView);
scrollView->setAnchorPoint(ccp(0.5,0.5));
scrollView->setPosition(ccp(10,size.height*0.23));
//3.setOption
scrollView->setBounceable(true);
scrollView->setViewSize(CCSizeMake(size.width, size.height*0.55));
scrollView->setContainer(container);
scrollView->setDirection(kCCScrollViewDirectionVertical);
scrollView->setTouchEnabled(true);
scrollView->setDelegate(this);
scrollView->unscheduleAllSelectors();
//4.closeMenu
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"ZF_Shoot_button_coinList_back2.png",
"ZF_Shoot_button_coinList_back1.png",
this,
menu_selector(GuideScene::menuCloseCallBack) );
pCloseItem->setPosition( CCPointMake(size.width*0.5-235 , size.height*0.92) );
pCloseItem->setTag(5);
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
addChild(pMenu);
return true;
}
示例3: updatePages
void CCScrollLayer::updatePages()
{
// Loop through the array and add the screens if needed.
int i = 0;
CCObject* object = NULL;
CCARRAY_FOREACH(m_pLayers, object)
{
CCLayer* layer = (CCLayer*)object;
layer->setAnchorPoint(ccp(0,0));
layer->setContentSize(CCDirector::sharedDirector()->getWinSize());
layer->setPosition(ccp((i * (m_tContentSize.width - m_fPagesWidthOffset)), 0));
if (!layer->getParent())
addChild(layer);
i++;
}
示例4: onLoadScene
void MenuScene::onLoadScene()
{
m_vMenuItems.push_back("Basic Test");
CCSize tContainerSize = CCSize(700, 100 * m_vMenuItems.size());
CCLayer* pScrollViewContainer = CCLayer::create();
pScrollViewContainer->setPosition(CCPointZero);
pScrollViewContainer->setContentSize(tContainerSize);
m_pScrollView = CCScrollView::create(CCSize(700, 640));
m_pScrollView->setDirection(kCCScrollViewDirectionVertical);
m_pScrollView->ignoreAnchorPointForPosition(false);
m_pScrollView->setPosition(CCPoint(480, 320));
m_pScrollView->setContainer(pScrollViewContainer);
addChild(m_pScrollView);
CCArray* pArray = CCArray::create();
float height = tContainerSize.height;
unsigned int i = 0;
unsigned int end = m_vMenuItems.size();
for(; i < end; ++i )
{
CCMenuItemFont* pFont = CCMenuItemFont::create(m_vMenuItems[i].c_str());
pFont->setTarget(this, menu_selector(MenuScene::onClick));
pFont->setFontSizeObj(45.0f);
pFont->setPosition(ccp(700 / 2, height - 100 / 2));
pFont->setTag(i + 1);
pArray->addObject(pFont);
height -= 100;
}
CCMenu* pMenu = CCMenu::createWithArray(pArray);
pMenu->setPosition(ccp(0,0));
pScrollViewContainer->addChild(pMenu);
m_pScrollView->setContentOffset(ccp(0, -(tContainerSize.height - 640)));
}
示例5: 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;
}
示例6: init
bool LeaderBoard::init()
{
if (!CCLayer::init())
return false;
//float iMenuWidthOffset = 0.55;
SCREEN_WIDTH = CCDirector::sharedDirector()->getWinSize().width;
SCREEN_HEIGHT = CCDirector::sharedDirector()->getWinSize().height;
CCSprite* bgsprite =ThemeManager::sharedInstance()->spriteWithImageFile("leaderboard.png");
bgsprite->setScaleX(SCREEN_WIDTH/bgsprite->getContentSize().width);
bgsprite->setScaleY(SCREEN_HEIGHT/bgsprite->getContentSize().height);
bgsprite->setPosition(ccp(SCREEN_WIDTH/2, SCREEN_HEIGHT/2));
this->addChild(bgsprite,1);
CCSprite* updateNicknamelb =ThemeManager::sharedInstance()->spriteWithImageFile("btn_update_nickname.png");
CCSprite* updateNicknameSelectedlb =ThemeManager::sharedInstance()->spriteWithImageFile("btn_update_nickname.png");
updateNicknameSelectedlb->setScale(1.1);
CCMenuItemSprite* pupdateNicknameItemSpritelb = CCMenuItemSprite::itemWithNormalSprite(updateNicknamelb, updateNicknameSelectedlb, this, menu_selector(LeaderBoard::updateNicknameClick));
pupdateNicknameItemSpritelb->setScale(LL_BUTTON_SCALE_VALUE);
CCMenu* pupdateNicknameMenu = CCMenu::menuWithItems(pupdateNicknameItemSpritelb,NULL);
pupdateNicknameMenu->setPosition(ccp(SCREEN_WIDTH*0.3, SCREEN_HEIGHT*0.15));
this->addChild(pupdateNicknameMenu, 3);
CCSprite* back2menuNormallb =ThemeManager::sharedInstance()->spriteWithImageFile("back2menu.png");
CCSprite* back2menuSelectedlb =ThemeManager::sharedInstance()->spriteWithImageFile("back2menu.png");
back2menuSelectedlb->setScale(1.1);
CCMenuItemSprite* pback2menuItemSpritelb = CCMenuItemSprite::itemWithNormalSprite(back2menuNormallb, back2menuSelectedlb, this, menu_selector(LeaderBoard::back2menuClick));
pback2menuItemSpritelb->setScale(LL_BUTTON_SCALE_VALUE);
CCMenu* pback2menuMenu = CCMenu::menuWithItems(pback2menuItemSpritelb,NULL);
pback2menuMenu->setPosition(ccp(SCREEN_WIDTH*0.7, SCREEN_HEIGHT*0.15));
this->addChild(pback2menuMenu, 3);
CCLayer *bg = CCLayer::create();
bg->setContentSize(CCSizeMake(SCREEN_WIDTH,SCREEN_HEIGHT*0.58));
bg->setAnchorPoint(ccp(0,0));
bg->setPosition(ccp(0,0));
char buff[16];
*buff = 0;
for(int i=0;i<10;i++){
int offsetHeight = SCREEN_HEIGHT*(0.63125-0.0583*i-0.08);
sprintf(buff,"%d ",i+1);
scoreLabel=CCLabelTTF::labelWithString(buff,CCSizeMake(300*LL_SCREEN_SCALE_VALUE,32), kCCTextAlignmentLeft,kCCVerticalTextAlignmentCenter,ThemeManager::sharedInstance()->getFontName(),36*LL_SCREEN_SCALE_VALUE);
scoreLabel->setPosition(ccp(SCREEN_WIDTH*0.43,offsetHeight));
scoreLabel->setColor(ThemeManager::sharedInstance()->getColor());
bg->addChild(scoreLabel, 4);
scoreLabel=CCLabelTTF::labelWithString(getNicknameByRank(i+1),CCSizeMake(300*LL_SCREEN_SCALE_VALUE,32), kCCTextAlignmentLeft,kCCVerticalTextAlignmentCenter,ThemeManager::sharedInstance()->getFontName(),36*LL_SCREEN_SCALE_VALUE);
scoreLabel->setPosition(ccp(SCREEN_WIDTH*0.50,offsetHeight));
scoreLabel->setColor(ThemeManager::sharedInstance()->getColor());
bg->addChild(scoreLabel, 4);
sprintf(buff,"%d ",getScore(i+1));
scoreLabel=CCLabelTTF::labelWithString(buff,CCSizeMake(150*LL_SCREEN_SCALE_VALUE,32), kCCTextAlignmentRight,kCCVerticalTextAlignmentCenter,ThemeManager::sharedInstance()->getFontName(),36*LL_SCREEN_SCALE_VALUE);
scoreLabel->setPosition(ccp(SCREEN_WIDTH*0.78,offsetHeight));
scoreLabel->setColor(ThemeManager::sharedInstance()->getColor());
bg->addChild(scoreLabel, 4);
}
CCScrollView * view = CCScrollView::create(CCSizeMake(SCREEN_WIDTH,SCREEN_HEIGHT*0.35), bg);
view->setDirection(kCCScrollViewDirectionVertical);
view->setContentSize( CCSizeMake(SCREEN_WIDTH,SCREEN_HEIGHT*0.58) );
view->setContentOffset(ccp(0,-SCREEN_HEIGHT*0.226));
view->setAnchorPoint(ccp(0,0));
view->setPosition(0,SCREEN_HEIGHT*0.305);
this->addChild(view,4);
sprintf(buff,"%d ",getBestScore());
scoreLabel=CCLabelTTF::labelWithString(buff,CCSizeMake(150*LL_SCREEN_SCALE_VALUE,32), kCCTextAlignmentRight,kCCVerticalTextAlignmentCenter,ThemeManager::sharedInstance()->getFontName(),36*LL_SCREEN_SCALE_VALUE);
scoreLabel->setPosition(ccp(SCREEN_WIDTH*0.78,SCREEN_HEIGHT*(0.62725-0.0583*6)));
scoreLabel->setColor(ThemeManager::sharedInstance()->getColor());
this->addChild(scoreLabel, 4);
scoreLabel=CCLabelTTF::labelWithString(getNickname(),CCSizeMake(300*LL_SCREEN_SCALE_VALUE,32), kCCTextAlignmentLeft,kCCVerticalTextAlignmentCenter,ThemeManager::sharedInstance()->getFontName(),36*LL_SCREEN_SCALE_VALUE);
scoreLabel->setPosition(ccp(SCREEN_WIDTH*0.51,SCREEN_HEIGHT*(0.62725-0.0583*6)));
scoreLabel->setColor(ThemeManager::sharedInstance()->getColor());
this->addChild(scoreLabel, 4);
/*char buff2[256];
*buff2 = 0;
sprintf(buff2,"%d %s",getUserRank(), getNickname());
scoreLabel=CCLabelTTF::labelWithString(buff2,CCSizeMake(330*LL_SCREEN_SCALE_VALUE,32), kCCTextAlignmentLeft,kCCVerticalTextAlignmentCenter,ThemeManager::sharedInstance()->getFontName(),36*LL_SCREEN_SCALE_VALUE);
scoreLabel->setPosition(ccp(SCREEN_WIDTH*0.43,SCREEN_HEIGHT*(0.63125-0.0583*7)));
scoreLabel->setColor(ThemeManager::sharedInstance()->getColor());
this->addChild(scoreLabel, 4);*/
return true;
}
示例7: createLevelsLayer
void LevelScene::createLevelsLayer()
{
CCArray *pLayers = CCArray::create();
CCArray *pLevels = m_pKategoria->getPantailak();
int numLevels = pLevels->count();
int numberPages = numLevels / 4;
if (numLevels % 4 > 0) {
numberPages++;
}
int cont = 0;
for (int i = 1; i <= numberPages; i++) {
CCLayer *pContainer = CCLayer::create();
CCLayer *pContentLayer = CCLayer::create();
CCSize contentSize = CCSizeMake(500, 490);
CCPoint contentPos = ccp(VisibleRect::center().x - contentSize.width/2, VisibleRect::center().y - contentSize.height/2);
pContentLayer->setContentSize(contentSize);
pContentLayer->setPosition(contentPos);
CCPoint texturePosition[] = {ccp(122, 369), ccp(372, 369), ccp(122, 149), ccp(372, 149)};
CCPoint labelPosition[] = {ccp(125, 250), ccp(375, 250), ccp(125, 30), ccp(375, 30)};
int numberRows = numLevels - (4 * (i-1));
if (numberRows > 4)
numberRows = 4;
for(int j = 1; j <= numberRows; j++) {
LevelModel *pLevel = (LevelModel*) pLevels->objectAtIndex(cont);
std::string imageName = CCFileUtils::sharedFileUtils()->getWriteablePath().append(pLevel->getList());
CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage("borde.png");
SpriteButton *pLevelButton = SpriteButton::create(pTexture ,this, callfuncO_selector(LevelScene::levelClicked));
pLevelButton->setPosition(texturePosition[j-1]);
pLevelButton->setTag(cont);
pTexture = CCTextureCache::sharedTextureCache()->addImage(imageName.c_str());
CCSprite *pImageBorder = CCSprite::createWithTexture(pTexture);
//pImageBorder->setAnchorPoint(ccp(0, 0));
pImageBorder->setScale(imageScale);
pImageBorder->setPosition(ccp(87, 95));
pLevelButton->addChild(pImageBorder);
pContentLayer->addChild(pLevelButton);
CCLabelTTF *pLabel = CCLabelTTF::create(pLevel->getIzena(), fontList[0], 22.0);
pLabel->setPosition(labelPosition[j-1]);
pLabel->setColor(ccc3(63, 62, 62));
pLabel->setDimensions(CCSizeMake(257, 50));
pContentLayer->addChild(pLabel);
cont++;
}
pContainer->addChild(pContentLayer);
pLayers->addObject(pContainer);
}
CCScrollLayer *pScrollLayer = CCScrollLayer::nodeWithLayers(pLayers, 0);
pScrollLayer->setPagesIndicatorPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y + 70));
pScrollLayer->setDelegate(this);
pScrollLayer->moveToPage(0);
addChild(pScrollLayer);
}
示例8: init
bool ScrollScene::init()
{
if ( !RecipeBase::init() )
{
return false;
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCLayer* scrollContainer = CCLayer::create(); // Container for the scroll view
scrollContainer->setAnchorPoint(CCPointZero); // CCScrollView does this too when it's set as the container.
CCLayerColor* panelBg = CCLayerColor::create(ccc4(51, 51, 51, 255),640,2000);
panelBg->setPosition(ccp(0,0));
scrollContainer->addChild(panelBg,2);
// Content for the container
CCSprite *tallContentA = CCSprite::create("image/quest/05ev_210222.png");
tallContentA ->setPosition(ccp(winSize.width*0.5f, 700));
CCSprite *tallContentB = CCSprite::create("image/quest/07ev_210232.png");
tallContentB ->setPosition(ccp(winSize.width*0.5f, 200));
CCSprite *tallContentC = CCSprite::create("image/quest/07ev_210232.png");
tallContentC ->setPosition(ccp(winSize.width*0.5f, 900));
CCSprite *tallContentD = CCSprite::create("image/quest/07ev_210232.png");
tallContentD ->setPosition(ccp(winSize.width*0.5f, 1400));
scrollContainer->addChild(tallContentA, 2);
scrollContainer->addChild(tallContentB, 2);
scrollContainer->addChild(tallContentC, 2);
scrollContainer->addChild(tallContentD, 2);
float scrollContainerHeight = tallContentA->getContentSize().height + tallContentB->getContentSize().height;
scrollContainer->setPosition(CCPointZero);
scrollContainer->setContentSize(CCSizeMake(640, 2000));
// Set up scroll view
cocos2d::extension::CCScrollView* scrollView = cocos2d::extension::CCScrollView::create(ccp(640, 960), scrollContainer);
scrollView->setPosition(ccp(0, 100));
scrollView->setDirection(cocos2d::extension::kCCScrollViewDirectionVertical);
// ScrollView initializes at the (left, bottom). The container also gets positioned relative to that and goes Y-up.
// Pre-set it to the value CCScrollView::minContainerOffset will return when it's scrolled to the top
// (note, this is a negative number, indicating the touch moving downwards, i.e. it's pre-scrolled such that the top of the content is visible when we begin)
scrollView->setContentOffset(ccp(0, 0));
CCLOG("test : %f",winSize.height-scrollContainerHeight*1.05f);
/*
// (StackOverflow Post Edit: This hack is not required.)
// Hack: CCScrollView's maxContainerOffset is (0, 0) and minContainerOffset is (difference between view and content size which is negative)
// It's designed to be (left, bottom) based and positive scrolling means showing stuff above the top of the screen.
// Since we're using it in terms of Window coordinates ((left, top) based), we scale the scroll view
// and it's container's children by -1 and position the children differently
// (eg. Y position winSize.height*0.1f was changed to winSize.height*0.9f)
// We can't just set the scroll view's Y scale to -1 because CCNode::getScale asserts that X and Y scale must be the same.
scrollView->setScale(-1.f);
tallContentA->setScale(-1.f);
tallContentB->setScale(-1.f);
*/
this->addChild(scrollView);
return true;
}
示例9: MakeScroll
void RequestTopaz::MakeScroll()
{
scrollContainer = CCLayer::create();
int numOfList = friendList.size();
int height = 0;
char fname[50], fname2[50];
for (int i = numOfList-1 ; i >= 0 ; i--)
{
if (friendList[i]->GetKakaoId() == myInfo->GetKakaoId())
continue;
// 요청시간이 아직 남아있는 친구는 리스트에 보이지 않게 한다.
if (friendList[i]->GetRemainRequestTopazTime() > 0)
continue;
CCLayer* itemLayer = CCLayer::create();
itemLayer->setContentSize(CCSizeMake(862, 166));
itemLayer->setPosition(ccp(34, height*166));
scrollContainer->addChild(itemLayer, 2);
spriteClassScroll->layers.push_back(itemLayer);
height++;
// 프로필 이미지
sprintf(fname, "background/bg_profile.png%d", i);
ProfileSprite* psp = ProfileSprite::GetObj(friendList[i]->GetImageUrl());
if (friendList[i]->GetImageUrl() != "" && psp->IsLoadingDone())
{
spriteClassScroll->spriteObj.push_back( SpriteObject::CreateFromSprite(0, psp->GetProfile(), ccp(0, 0), ccp(35+5, 35+11), CCSize(0,0), "", "Layer", itemLayer, 3, 0, 255, 0.95f) );
sprintf(fname, "background/bg_profile.png%d", i);
spriteClassScroll->spriteObj.push_back( SpriteObject::Create(0, fname, ccp(0, 0), ccp(35, 35), CCSize(0, 0), "", "Layer", itemLayer, 3) );
}
else
{
spriteClassScroll->spriteObj.push_back( SpriteObject::CreateFromSprite(0, psp->GetProfile(), ccp(0, 0), ccp(35, 35), CCSize(0,0), "", "Layer", itemLayer, 3, 0, 255, 1.0f, -888*(numOfList-i)) ); // tag = -888 * (i+1)
spriteClassScroll->spriteObj.push_back( SpriteObject::Create(0, fname, ccp(0, 0), ccp(35, 35), CCSize(0, 0), "", "Layer", itemLayer, 3, 0, 255, -777*(numOfList-i)) ); // tag = -777 * (i+1)
}
// name (text)
spriteClassScroll->spriteObj.push_back( SpriteObject::CreateLabel(friendList[i]->GetNickname(), fontList[0], 48, ccp(0, 0), ccp(196, 71), ccc3(78,47,8), "", "Layer", itemLayer, 3) );
// button
sprintf(fname, "button/btn_yellow_mini.png%d", i);
spriteClassScroll->spriteObj.push_back( SpriteObject::Create(0, fname, ccp(0, 0), ccp(635, 34), CCSize(0, 0), "", "Layer", itemLayer, 3, 0, 255, i*100) ); // 버튼에 친구 kakao id를 tag로 둔다.
sprintf(fname2, "letter/letter_request2.png%d", i);
spriteClassScroll->spriteObj.push_back( SpriteObject::Create(0, fname2, ccp(0.5, 0), ccp(spriteClassScroll->spriteObj[spriteClassScroll->spriteObj.size()-1]->sprite->getContentSize().width/2, 24), CCSize(0, 0), fname, "0", NULL, 3) );
// dotted line
if (i < numOfList-1)
{
sprintf(fname, "background/bg_dotted_line.png%d", i);
spriteClassScroll->spriteObj.push_back( SpriteObject::Create(0, fname, ccp(0, 0), ccp(0, 5), CCSize(0, 0), "", "Layer", itemLayer, 3) );
}
}
for (int i = 0 ; i < spriteClassScroll->spriteObj.size() ; i++)
spriteClassScroll->AddChild(i);
// container 생성
scrollContainer->setContentSize(CCSizeMake(862, height*166));
scrollView->setContainer(scrollContainer);
scrollView->setContentSize(scrollContainer->getContentSize());
scrollView->setContentOffset(ccp(0, scrollView->minContainerOffset().y), false);
}
示例10: newScrolling
void SelectCollection::newScrolling(MenuSpriteBatch* menu)
{
//Get the size of the screen we can see
CCSize visibleSize = Screen::getVisibleSize();
float scaled = Screen::getScaleFactor();
//Get the screen start of cordinates
CCPoint origin = Screen::getOrigin();
const float TOP_MARGIN = 140/scaled;
const float BOTTOM_MARGIN = 30/scaled;
float menu_left_padding = 0;
float min_height = 1000/scaled;
CCSize menu_size = menu->getContentSize();
float collection_height = menu_size.height;
if(collection_height < min_height)
{
collection_height = min_height;
menu_left_padding = (min_height - menu_size.height) / 2;
}
//Get the scroll area size
float scroll_view_width = visibleSize.width - TOP_MARGIN * 0.2;
float scroll_view_height = visibleSize.height-TOP_MARGIN - BOTTOM_MARGIN;
CCSize scroll_view_size(scroll_view_width, scroll_view_height);
//Create layer to fit all tiles
CCLayer *layer = CCLayer::create();
layer->setContentSize(CCSize(menu_size.width, menu_size.height));
//Create scroll view for this layer
CCScrollView* _collections_scroll_view = CCScrollView::create(
scroll_view_size,layer);
CCPoint collections_target_position(
origin.x + visibleSize.width/2 - scroll_view_size.width/2,
origin.y + BOTTOM_MARGIN);
float scale = scroll_view_width/menu_size.width;
layer->setScale(scale);
_collections_scroll_view->setPosition(collections_target_position);
_collections_scroll_view->setAnchorPoint(ccp(0.5, 0));
//CCRect eat_zone(origin.x,origin.y, visibleSize.width, _collections_scroll_view->getPositionY() + scroll_view_height);
CCRect eat_zone(origin.x,origin.y,
visibleSize.width,
visibleSize.height);
_collections_scroll_view->setTouchEatZone(eat_zone);
_collections_scroll_view->updateInset();
_collections_scroll_view->setDirection(kCCScrollViewDirectionVertical);
_collections_scroll_view->setContentOffset(_collections_scroll_view->minContainerOffset());
this->addChild(_collections_scroll_view);
//Add our tiles to scroll area
_collections_scroll_view->addChild(menu);
_collections_scroll_view->setMenu(menu->menu());
_collections_scroll_view->addHighPriorityTouchListener(_back_menu);
// this->addChild(menu);
menu->setAnchorPoint(ccp(0,0));
menu->setPosition(ccp(0,
0));
_pop_up_manager.addOnHideWindowAction([_collections_scroll_view](){
_collections_scroll_view->setTouchEnabled(true);
});
_pop_up_manager.addOnShowWindowAction([_collections_scroll_view](){
_collections_scroll_view->setTouchEnabled(false);
});
_pop_up_manager.addMenuToAutoDisable(menu->menu());
}
示例11: viewDidLoad
void SGAnnouncementLayer::viewDidLoad(main::AnnouncementResponse &response)//cgp come
{
this->setTouchEnabled(true);
this->setTag(box_announcementLayer);
ResourceManager::sharedInstance()->bindTexture("sgannouncementlayer/sgannouncementlayer.plist", RES_TYPE_LAYER_UI, sg_announcementLayer);
ResourceManager::sharedInstance()->bindTexture("sgannouncementlayer/sgannouncementlayer2.plist", RES_TYPE_LAYER_UI, sg_announcementLayer);
ResourceManager::sharedInstance()->bindTexture("sglandingreward/sglandingreward.plist", RES_TYPE_LAYER_UI, sg_announcementLayer);
ResourceManager::sharedInstance()->bindTexture("sanguobigpic/Tips.plist", RES_TYPE_LAYER_UI, sg_announcementLayer);
m_arrayAnn = CCArray::create();
m_arrayAnn->retain();
//CCPoint center = SGLayout::getPoint(kMiddleCenter);
//加个半透明黑背景
CCLayerColor *blackLayer = CCLayerColor::create(ccc4(0, 0, 0, 150), SGLayout::getSkewing(380), SGLayout::getSkewingY(520));
blackLayer->setPosition(ccpAdd(ccp(0, 0), ccp(-385, -570)));
addChild(blackLayer);
//大个背景
// CCSprite *sprite_background = CCSprite::create("gonggao/gonggao_bj.png");
CCSprite *sprite_background = CCSprite::createWithSpriteFrameName("bg.png");
addChild(sprite_background);
//cgp useful
//按钮
buttonOK = SGButton::create("gonggao_an.png", "public_font_queding.png", this, menu_selector(SGAnnouncementLayer::buttonClickOK),CCPointZero,false,true);
buttonOK->setPosition(ccp(sprite_background->getContentSize().width * 0.5 - 5, sprite_background->getContentSize().height * 0.05));
// addBtn(buttonOK);
//遮挡住按钮穿透,临时做法
SGButton *mask = SGButton::create("gonggao_an.png", NULL, this, menu_selector(SGAnnouncementLayer::pressMask), CCPointZero, false, true);
mask->setScaleY(0.3);
mask->setOpacity(0);
mask->setPosition(ccp(buttonOK->getPositionX(), buttonOK->getPositionY() + 40));
menu = CCMenu::create(buttonOK, mask, NULL);
menu->setTag(254);
menu->setPosition(CCPointZero);
sprite_background->addChild(menu);
//CCScrollView
m_scrollview = CCScrollView::create(CCSizeMake(574, 761));
CCLayer *container = CCLayer::create();
container->setContentSize(CCSizeMake(574, 770));
m_scrollview->setContainer(container);
CCSize backgroundSize = sprite_background->getContentSize();
m_scrollview->setPosition(ccpAdd(ccp(0, 0), ccp(-287, -382)));//设置scrollview位置
m_scrollview->setDirection(kCCScrollViewDirectionVertical);
addChild(m_scrollview);
//解析接收到的数据
int modelSize = response.announcementmodel_size();
for(int i = 0;i < modelSize;i++)
{
main::AnnouncementModel model = response.announcementmodel(i);
SGAnnouncementDataModel *ann = new SGAnnouncementDataModel();
//ann->setTimeStamp(model.timestamp());
ann->setTitle(CCString::create(model.title()));
ann->setContent(CCString::create(model.content()));
ann->setViewId(model.viewid());
if (model.url() != "")//如果url不为空才设置对应的url
{
ann->setUrl(CCString::create(model.url()));
}
m_arrayAnn->addObject(ann);
ann->autorelease();
}
//constructScrollView();
initScrollView();
//removed by cgp
//this->flowerEffect();//花瓣效果
// buttonClickOK();
}
示例12: CCLOG
//.........这里部分代码省略.........
}
for (int i = 0; i<(int)showPicMap.size()/4+1; i++){
if (4*(i+1)<=mapSize) {
for (int j = 0; j<4; j++)
{
const char * imageName = showPicMap[PersonalApi::convertIntToString(indexNum)].c_str();
string str=PersonalApi::getRealImageName(imageName,"S15Small_1.png").c_str();
CCLOG("aaaaa%s",str.c_str());
CCMenuItemImage * aItemImage = CCMenuItemImage::create(str.c_str(),
str.c_str(),
this,
menu_selector(S65ShowVideo::S15DetailCallback));
aItemImage->setPosition(ccp(3+145+(aItemImage->getContentSize().width+31)*j,scrollMaxSizeY-elementHeight/2-elementHeight*i));//showSize.height-elementHeight*1.5+(aItemImage->getContentSize().height+20)*i)
FDMenu * detailMenu = FDMenu::create();
detailMenu ->setPosition(CCPointZero);
detailMenu->addChild(aItemImage,zNum);
pLayer->addChild(detailMenu,zNum);
aItemImage->setTag(btnTag+indexNum);
if (i==0&&j<2)
{
aItemImage->setOpacity(1);
}
indexNum++;
}
}else{
for (int j = 0; j<mapSizeRemainder; j++)
{
CCLog("pppppp");
const char * imageName = showPicMap[PersonalApi::convertIntToString(indexNum)].c_str();
string str=PersonalApi::getRealImageName(imageName,"S15Small_1.png").c_str();
// CCLOG("aaaaa%s",str.c_str());
CCMenuItemImage * aItemImage = CCMenuItemImage::create(str.c_str(),
str.c_str(),
this,
menu_selector(S65ShowVideo::S15DetailCallback));
aItemImage->setPosition(ccp(3+145+(aItemImage->getContentSize().width+31)*j,scrollMaxSizeY-elementHeight/2-elementHeight*(i)));//scrollMaxSizeY-elementHeight/2+elementHeight*i) scrollMaxSizeY-elementHeight/2-elementHeight*(mapSizeAver-i-1)
FDMenu * detailMenu = FDMenu::create();
detailMenu ->setPosition(CCPointZero);
detailMenu->addChild(aItemImage,zNum);
pLayer->addChild(detailMenu,zNum);
aItemImage->setTag(btnTag+indexNum);
indexNum++;
}
}
if(i==0){
const char * imageName = "S45ScrollBigPic1.png";//showBigPicMap[PersonalApi::convertIntToString(i+1)].c_str();
string str=PersonalApi::getRealImageName(imageName,"S15Big_1.png").c_str();
CCMenuItemImage * aItemImage = CCMenuItemImage::create(str.c_str(),
str.c_str(),
this,
menu_selector(S65ShowVideo::S15DetailCallback));
aItemImage->setAnchorPoint(CCPointZero);
aItemImage->setPosition(ccp(36,2+scrollMaxSizeY-elementHeight*2+elementHeight*i));
if (1 == (int)showPicMap.size()/4+1)
{
aItemImage->setPosition(ccp(36,-(aItemImage->getContentSize().height-30)-2+scrollMaxSizeY-elementHeight*2+elementHeight*i));
}
FDMenu * detailMenu = FDMenu::create();
detailMenu ->setPosition(CCPointZero);
detailMenu->addChild(aItemImage,zNum);
pLayer->addChild(detailMenu,zNum+1);
aItemImage->setTag(btnTag+indexNum-3);
}
}
m_pScrollView->setTouchEnabled(true);
pLayer->setContentSize(CCSizeMake(showSize.width, scrollMaxSizeY));
m_pScrollView->setContentOffset(ccp(0,-(scrollMaxSizeY-showSize.height)));
m_pScrollView->setDirection(kCCScrollViewDirectionVertical);
m_pScrollView->setDelegate(this);
this->addChild(m_pScrollView);
bRet = true;
} while (0);
return bRet;
}
示例13: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
/////////////////////////////
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
pLabel = CCLabelTTF::create("Hello World", "Thonburi", 34);
// ask director the window size
CCSize size = CCDirector::sharedDirector()->getWinSize();
// position the label on the center of the screen
pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
// add the label as a child to this layer
this->addChild(pLabel, 1);
// CCScrollView
scrollView = CCScrollView::create();
CCLayer *layer = CCLayer::create();
CCSprite *sprite1 = CCSprite::create("HelloWorld.png");
CCSprite *sprite2 = CCSprite::create("HelloWorld.png");
layer->setAnchorPoint(CCPointZero);
layer->setPosition(CCPointZero);
// Menu
CCMenuItemSprite *menuItem1 = CCMenuItemSprite::create(sprite1, sprite1, this, menu_selector(HelloWorld::menu1Callback));
menuItem1->setPosition(ccpAdd(CCPointZero, ccp(size.width / 2, size.height / 2)));
menuItem1->setScale(0.4f);
CCMenuItemSprite *menuItem2 = CCMenuItemSprite::create(sprite2, sprite2, this, menu_selector(HelloWorld::menu2Callback));
menuItem2->setPosition(ccpAdd(ccp(480, 0), ccp(size.width / 2, size.height / 2)));
menuItem2->setScale(0.4f);
CCMenu *menu = CCMenu::create(menuItem1, menuItem2, NULL);
menu->setPosition(CCPointZero);
layer->addChild(menu);
scrollView->setPosition(CCPointZero);
scrollView->setContentOffset(CCPointZero);
layer->setContentSize(CCSizeMake(960, 320));
scrollView->setContentSize(CCSizeMake(480, 320));
scrollView->setContainer(layer);
// 设置滚屏属性
scrollView->setDirection(CCScrollViewDirectionHorizontal);
scrollView->setDelegate(this);
this->addChild(scrollView);
return true;
}
示例14: MakeScroll
void CocoRoomTodayCandy::MakeScroll()
{
int numOfList = friendList.size();
// init select array
selected.clear();
for (int i = 0 ; i < numOfList ; i++)
selected.push_back(false);
// make scroll
scrollContainer = CCLayer::create();
scrollContainer->setPosition(ccp(77, 492+904+243));
//scrollContainer->setContentSize(CCSizeMake(862, (numOfList-1)*166));
int height = 0;
char fname[50], fname2[50];
for (int i = numOfList-1 ; i >= 0 ; i--)
{
if (friendList[i]->GetKakaoId() == myInfo->GetKakaoId())
continue;
CCLayer* itemLayer = CCLayer::create();
itemLayer->setContentSize(CCSizeMake(862, 166));
//itemLayer->setPosition(ccp(34, (numOfList-1-height)*166));
itemLayer->setPosition(ccp(34, height*166));
scrollContainer->addChild(itemLayer, 2);
spriteClass->layers.push_back(itemLayer);
height++;
// 프로필 이미지
sprintf(fname, "background/bg_profile.png%d", i);
ProfileSprite* psp = ProfileSprite::GetObj(friendList[i]->GetImageUrl());
if (friendList[i]->GetImageUrl() != "" && psp->IsLoadingDone())
{
spriteClass->spriteObj.push_back( SpriteObject::CreateFromSprite(0, psp->GetProfile(), ccp(0, 0), ccp(35+5, 35+11), CCSize(0,0), "", "Layer", itemLayer, 3, 0, 255, 0.95f) );
sprintf(fname, "background/bg_profile.png%d", i);
spriteClass->spriteObj.push_back( SpriteObject::Create(0, fname, ccp(0, 0), ccp(35, 35), CCSize(0, 0), "", "Layer", itemLayer, 3) );
}
else
{
spriteClass->spriteObj.push_back( SpriteObject::CreateFromSprite(0, psp->GetProfile(), ccp(0, 0), ccp(35, 35), CCSize(0,0), "", "Layer", itemLayer, 3, 0, 255, 1.0f, -888*(numOfList-i)) ); // tag = -888 * (i+1)
spriteClass->spriteObj.push_back( SpriteObject::Create(0, fname, ccp(0, 0), ccp(35, 35), CCSize(0, 0), "", "Layer", itemLayer, 3, 0, 255, -777*(numOfList-i)) ); // tag = -777 * (i+1)
}
// name (text)
spriteClass->spriteObj.push_back( SpriteObject::CreateLabel(friendList[i]->GetNickname(), fontList[0], 48, ccp(0, 0), ccp(196, 71), ccc3(78,47,8), "", "Layer", itemLayer, 3) );
// button
sprintf(fname, "button/btn_blue_mini.png%d", i);
spriteClass->spriteObj.push_back( SpriteObject::Create(0, fname, ccp(0, 0), ccp(635, 34+3), CCSize(0, 0), "", "Layer", itemLayer, 3, 0, 255) );
sprintf(fname2, "letter/letter_select.png%d", i);
spriteClass->spriteObj.push_back( SpriteObject::Create(0, fname2, ccp(0.5, 0), ccp(spriteClass->spriteObj[spriteClass->spriteObj.size()-1]->sprite->getContentSize().width/2, 24), CCSize(0, 0), fname, "0", NULL, 3, 1, 255) );
/*if (friendList[i]->GetPotionMsgStatus() == 0)
{
((CCSprite*)spriteClass->FindSpriteByName(fname))->setColor(ccc3(150,150,150));
((CCSprite*)spriteClass->FindSpriteByName(fname2))->setColor(ccc3(150,150,150));
}*/
sprintf(fname, "button/btn_skill_master.png%d", i);
spriteClass->spriteObj.push_back( SpriteObject::Create(0, fname, ccp(0, 0), ccp(635, 34+6), CCSize(0, 0), "", "Layer", itemLayer, 3, 0, 0) );
sprintf(fname2, "letter/letter_select_brown.png%d", i);
spriteClass->spriteObj.push_back( SpriteObject::Create(0, fname2, ccp(0.5, 0), ccp(spriteClass->spriteObj[spriteClass->spriteObj.size()-1]->sprite->getContentSize().width/2, 27), CCSize(0, 0), fname, "0", NULL, 3, 1, 0) );
SetSelectMode(i);
// dotted line
//if (i < numOfList-1)
//{
sprintf(fname, "background/bg_dotted_line.png%d", i);
spriteClass->spriteObj.push_back( SpriteObject::Create(0, fname, ccp(0, 0), ccp(0, 5), CCSize(0, 0), "", "Layer", itemLayer, 3) );
//}
}
// container 생성 + offset
scrollContainer->setContentSize(CCSizeMake(862, height*166));
scrollView->setContainer(scrollContainer);
scrollView->setContentSize(scrollContainer->getContentSize());
scrollView->setContentOffset(ccp(0, scrollView->minContainerOffset().y), false);
}
示例15: init
//.........这里部分代码省略.........
lock4 = CCSprite::create("lock.png");
lock5 = CCSprite::create("lock.png");
lock6 = CCSprite::create("lock.png");
lock7 = CCSprite::create("lock.png");
lock8 = CCSprite::create("lock.png");
lock9 = CCSprite::create("lock.png");
lock10 = CCSprite::create("lock.png");
lock11 = CCSprite::create("lock.png");
lock12 = CCSprite::create("lock.png");
lock13 = CCSprite::create("lock.png");
lock14 = CCSprite::create("lock.png");
lock15 = CCSprite::create("lock.png");
item2->addChild(lock2);
item3->addChild(lock3);
item4->addChild(lock4);
item5->addChild(lock5);
item6->addChild(lock6);
item7->addChild(lock7);
item8->addChild(lock8);
item9->addChild(lock9);
item10->addChild(lock10);
item11->addChild(lock11);
item12->addChild(lock12);
item13->addChild(lock13);
item14->addChild(lock14);
item15->addChild(lock15);
addLock();
//创建层容器
CCLayer * containLayer = CCLayer::create();
containLayer->addChild(menu1);
containLayer->addChild(menu2);
containLayer->addChild(menu3);
containLayer->setContentSize(CCSizeMake(size.width * 4, size.height));
/*添加关数*/
CCLabelTTF* level1 = CCLabelTTF::create("1st", "Georgia-Bold", 45);
CCLabelTTF* level2 = CCLabelTTF::create("2nd", "Georgia-Bold", 45);
CCLabelTTF* level3 = CCLabelTTF::create("3rd", "Georgia-Bold", 45);
CCLabelTTF* level4 = CCLabelTTF::create("4th", "Georgia-Bold", 45);
CCLabelTTF* level5 = CCLabelTTF::create("5th", "Georgia-Bold", 45);
CCLabelTTF* level6 = CCLabelTTF::create("6th", "Georgia-Bold", 45);
CCLabelTTF* level7 = CCLabelTTF::create("7th", "Georgia-Bold", 45);
CCLabelTTF* level8 = CCLabelTTF::create("8th", "Georgia-Bold", 45);
CCLabelTTF* level9 = CCLabelTTF::create("9th", "Georgia-Bold", 45);
CCLabelTTF* level10 = CCLabelTTF::create("10th", "Georgia-Bold", 45);
CCLabelTTF* level11 = CCLabelTTF::create("11th", "Georgia-Bold", 45);
CCLabelTTF* level12 = CCLabelTTF::create("12th", "Georgia-Bold", 45);
CCLabelTTF* level13 = CCLabelTTF::create("13th", "Georgia-Bold", 45);
CCLabelTTF* level14 = CCLabelTTF::create("14th", "Georgia-Bold", 45);
CCLabelTTF* level15 = CCLabelTTF::create("15th", "Georgia-Bold", 45);
containLayer->addChild(level1);
containLayer->addChild(level2);
containLayer->addChild(level3);
containLayer->addChild(level4);
containLayer->addChild(level5);
containLayer->addChild(level6);
containLayer->addChild(level7);
containLayer->addChild(level8);
containLayer->addChild(level9);
containLayer->addChild(level10);
containLayer->addChild(level11);
containLayer->addChild(level12);
containLayer->addChild(level13);
containLayer->addChild(level14);
containLayer->addChild(level15);
level1->setPosition(ccp(size.width * 0.18, size.height * 0.4));
level2->setPosition(ccp(size.width * 0.34, size.height * 0.4));
level3->setPosition(ccp(size.width * 0.5, size.height * 0.4));
level4->setPosition(ccp(size.width * 0.657, size.height * 0.4));
level5->setPosition(ccp(size.width * 0.82, size.height * 0.4));
level6->setPosition(ccp(size.width * 1.18, size.height * 0.4));
level7->setPosition(ccp(size.width * 1.34, size.height * 0.4));
level8->setPosition(ccp(size.width * 1.5, size.height * 0.4));
level9->setPosition(ccp(size.width * 1.657, size.height * 0.4));
level10->setPosition(ccp(size.width * 1.82, size.height * 0.4));
level11->setPosition(ccp(size.width * 2.18, size.height * 0.4));
level12->setPosition(ccp(size.width * 2.34, size.height * 0.4));
level13->setPosition(ccp(size.width * 2.5, size.height * 0.4));
level14->setPosition(ccp(size.width * 2.657, size.height * 0.4));
level15->setPosition(ccp(size.width * 2.82, size.height * 0.4));
/*创建滚动视图*/
scrollView = CCScrollView::create(CCSizeMake(size.width*3, size.height));
addChild(scrollView);
scrollView->setBounceable(false);//设置scrollview有弹跳效果(默认为true)
scrollView->setViewSize(CCSizeMake(size.width*2, size.height));//设置scrollView尺寸
scrollView->setContainer(containLayer);//设置容器
scrollView->getViewSize();//获取视图尺寸
scrollView->setTouchEnabled(true);//开启监听多触点
scrollView->setDelegate(this);//注册监听
return true;
}