本文整理汇总了C++中CCLayerColor::setContentSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayerColor::setContentSize方法的具体用法?C++ CCLayerColor::setContentSize怎么用?C++ CCLayerColor::setContentSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLayerColor
的用法示例。
在下文中一共展示了CCLayerColor::setContentSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CCSizeMake
//测试图片滚动
void HelloWorld::test1()
{
CCSize visableSize = CCSizeMake(480, 320); //屏幕大小
CCSize mysize = CCSizeMake(960,600); //容器大小
//创建容器、设置大小
CCLayerColor* scrollLayer = CCLayerColor::create( ccc4(255,255,255,255) );
scrollLayer->setContentSize(mysize);
//容器中的东西
CCSprite* bg = CCSprite::create("war.png");
bg->setPosition( ccp(960/2.0, 600/2.0) );
scrollLayer->addChild(bg);
//创建滚动视图CCScrollView
CCScrollView* scrollView = CCScrollView::create();
this->addChild(scrollView, 0, 1);
//属性设置
scrollView->setContainer(scrollLayer); //设置容器
scrollView->setViewSize( visableSize ); //可视区域大小
scrollView->setBounceable(true); //是否具有弹性
//委托代理
scrollView->setDelegate(this);
}
示例2: init
bool LoginLayerUC::init()
{
BaseLayer::init();
m_ui = nullptr;
m_iCurrentType = LoginResponseMsg;
m_LayoutRoot = CWidgetWindow::create();
m_LayoutRoot->setTag(10000);
this->addChild(m_LayoutRoot);
CCLayerColor* pColor = CCLayerColor::create(ccc4(255, 255, 255, 255));
pColor->setContentSize(WINSIZE);
pColor->setPosition(CCPointZero);
m_LayoutRoot->addChild(pColor, -1);
//加载
CCArmatureDataManager::sharedArmatureDataManager()->addArmatureFileInfo("loginScene/opening.ExportJson");
//生成骨骼
m_armature = CCArmature::create("opening");
m_armature->setPosition(VCENTER);
m_LayoutRoot->addChild(m_armature);
//绑定动画事件
m_armature->getAnimation()->setMovementEventCallFunc(this, movementEvent_selector(LoginLayerUC::movementCallBack));
m_armature->getAnimation()->setFrameEventCallFunc(this, frameEvent_selector(LoginLayerUC::frameEventCallBack));
m_armature->getAnimation()->playWithIndex(0);
this->runAction(CCSequence::createWithTwoActions(CCDelayTime::create(2.8f), CCCallFunc::create(this, callfunc_selector(LoginLayerUC::callBackForSoundUp))));
return true;
}
示例3: init
bool bottonLayer::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
//CCSize size = CCDirector::sharedDirector()->getWinSize();
CCLayerColor *layer = CCLayerColor::create(ccc4(192, 192, 192, 255));
//CCLayer *layer = CCLayer::create();
layer->setContentSize(CCSizeMake(1280,168));
CCSprite *sprite1 = CCSprite::create("buttons/food.png");
CCSprite *sprite2 = CCSprite::create("buttons/game.png");
CCSprite *sprite3 = CCSprite::create("buttons/gift.png");
CCSprite *sprite4 = CCSprite::create("buttons/creat.png");
CCSprite *sprite5 = CCSprite::create("buttons/lib.png");
CCSprite *sprite6 = CCSprite::create("buttons/money.png");
CCSprite *sprite7 = CCSprite::create("buttons/setting.png");
CCSprite *sprite8 = CCSprite::create("buttons/talk.png");
int spriteSize = 64;
// Menu
CCMenuItemSprite *menuItem1 = CCMenuItemSprite::create(sprite1, sprite1, this, menu_selector(bottonLayer::menu1Callback));
menuItem1->setPosition(ccpAdd(ccp(16,20),ccp(spriteSize,spriteSize)));
CCMenuItemSprite *menuItem2 = CCMenuItemSprite::create(sprite2, sprite2, this, menu_selector(bottonLayer::menu2Callback));
menuItem2->setPosition(ccpAdd(ccp(176,20), ccp(spriteSize,spriteSize)));
CCMenuItemSprite *menuItem3 = CCMenuItemSprite::create(sprite3, sprite3, this, menu_selector(bottonLayer::menu3Callback));
menuItem3->setPosition(ccpAdd(ccp(336,20), ccp(spriteSize,spriteSize)));
CCMenuItemSprite *menuItem4 = CCMenuItemSprite::create(sprite4, sprite4, this, menu_selector(bottonLayer::menu4Callback));
menuItem4->setPosition(ccpAdd(ccp(496,20), ccp(spriteSize,spriteSize)));
CCMenuItemSprite *menuItem5 = CCMenuItemSprite::create(sprite5, sprite5, this, menu_selector(bottonLayer::menu3Callback));
menuItem5->setPosition(ccpAdd(ccp(656,20), ccp(spriteSize,spriteSize)));
CCMenuItemSprite *menuItem6 = CCMenuItemSprite::create(sprite6, sprite6, this, menu_selector(bottonLayer::menu3Callback));
menuItem6->setPosition(ccpAdd(ccp(816,20), ccp(spriteSize,spriteSize)));
CCMenuItemSprite *menuItem7 = CCMenuItemSprite::create(sprite7, sprite7, this, menu_selector(bottonLayer::menu3Callback));
menuItem7->setPosition(ccpAdd(ccp(976,20), ccp(spriteSize,spriteSize)));
CCMenuItemSprite *menuItem8 = CCMenuItemSprite::create(sprite8, sprite8, this, menu_selector(bottonLayer::menu3Callback));
menuItem8->setPosition(ccpAdd(ccp(1136,20), ccp(spriteSize,spriteSize)));
CCMenu *menu = CCMenu::create(menuItem1, menuItem2,menuItem3,menuItem4,menuItem5,menuItem6,menuItem7,menuItem8, NULL);
menu->setPosition(CCPointZero);
layer->addChild(menu);
scrollView = CCScrollView::create(); // 创建一个实例
scrollView->setContentSize(CCSizeMake(1080, 168)); //设置容器大小(内容尺寸)
scrollView->setViewSize(CCSizeMake(640, 168)); //设置显示(可视)范围
scrollView->setContainer(layer);
scrollView->setDirection( kCCScrollViewDirectionHorizontal );
scrollView->setTouchPriority(-130); //提升优先级到比ccMenu高
this->addChild(scrollView);
return true;
}
示例4: reloadData
void CTextRich::reloadData()
{
CCAssert(!m_pRichTextAtlas->empty(), "reload data was empty");
removeAllChildrenWithCleanup(true);
m_vRichTextAtlasDescriptions.clear();
m_uCharCursor = 0;
CCSize tRealContentSize = CCSizeZero;
int nRowBegin = m_pRichTextAtlas->size() - 1;
unsigned int uRowEnd = 0;
unsigned int uColumn = 0;
unsigned int uColumnSize = 0;
for(; nRowBegin >= (int)uRowEnd; --nRowBegin )
{
CTextRichAtlasLine* vAtlasLine = m_pRichTextAtlas->at(nRowBegin);
uColumnSize = vAtlasLine->size();
uColumn = 0;
float fWidgetOfLine = 0.0f;
float fMaxHeightOfLine = 0.0f;
for(; uColumn < uColumnSize; ++uColumn )
{
_ccTEXTRICHELEMENT& tElement = vAtlasLine->at(uColumn);
tElement.pATLASITEM->setPosition(CCPoint(fWidgetOfLine, tRealContentSize.height));
addChild(tElement.pATLASITEM);
#if 0
CCLayerColor* pColor = CCLayerColor::create(ccc4(255, 0,0, 129));
pColor->setPosition(CCPoint(fWidgetOfLine, tRealContentSize.height) + ccp(1, 1));
pColor->setContentSize(tElement.pATLASITEM->getContentSize() - CCSize(2,2));
addChild(pColor);
#endif
_ccTEXTRICHELEMENTRECT tDES;
tDES.tRECT = tElement.pATLASITEM->boundingBox();
tDES.strDESCRIPTION = tElement.strDESCRIPTION;
m_vRichTextAtlasDescriptions.push_back(tDES);
fWidgetOfLine += tElement.pATLASITEM->getContentSize().width;
fMaxHeightOfLine = MAX(fMaxHeightOfLine, tElement.pATLASITEM->getContentSize().height);
}
tRealContentSize.width = MAX(tRealContentSize.width, fWidgetOfLine);
tRealContentSize.height += fMaxHeightOfLine + m_fVerticalSpacing;
delete vAtlasLine;
}
m_pRichTextAtlas->clear();
tRealContentSize.height -= m_fVerticalSpacing;
setContentSize(tRealContentSize);
}
示例5: CCSizeMake
void LayerTest1::updateSize(CCPoint &touchLocation)
{
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCSize newSize = CCSizeMake( fabs(touchLocation.x - s.width/2)*2, fabs(touchLocation.y - s.height/2)*2);
CCLayerColor* l = (CCLayerColor*) getChildByTag(kTagLayer);
l->setContentSize( newSize );
}
示例6: initData
void GameWeekRewardLayer::initData()
{
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCLayerColor *backGround = CCLayerColor::create(ccc4(0, 0, 0, 150));
backGround->setContentSize(visibleSize);
backGround->setZOrder(0);
this -> addChild(backGround);
// add your codes here...
}
示例7: initView
void SpRuleInfoBox::initView()
{
CCPoint center = SGLayout::getPoint(kMiddleCenter);
fontbg->setPreferredSize(CCSizeMake(380, 380));
fontbg->setPosition(ccpAdd(fontbg->getPosition(), ccp(0, 25)));
SGCCLabelTTF *tips = SGCCLabelTTF::create(str_SpecialBattleIntro, FONT_PANGWA, 32 ,ccRED);
this->addChild(tips, 2);
tips->setPosition(ccpAdd(biao->getPosition(), ccp(0, 0)));
//可滚动规则视图
CCScrollView *m_scrollview = CCScrollView::create(CCSizeMake(350, 150));
m_scrollview->setViewSize(CCSizeMake(350, 360));
CCLayerColor *container = CCLayerColor::create(ccc4(0, 0, 0, 0));
container->setContentSize(CCSizeMake(350, 355));
m_scrollview->setContainer(container);
m_scrollview->setPosition(ccpAdd(center, ccp(-fontbg->getContentSize().width / 2, -fontbg->getContentSize().height / 2 + 30)));//设置scrollview位置
m_scrollview->setDirection(kCCScrollViewDirectionVertical);
this->addChild(m_scrollview);
m_scrollview->setTag(103);
//测试数据
int finalLen = 0;
int rankSize = 10;
SGStaticDataManager *mgr = SGStaticDataManager::shareStatic();
for (int i = 0; i < mgr->getSpHelpInfoKeysNum(); i++)
{
std::string info = SGStaticDataManager::shareStatic()->getSingleSpBattleRule(i);
if (info != "")
{
SGRuleItem *item = SGRuleItem::create(i, info.c_str());
container->addChild(item);
item->setPosition(ccpAdd(container->getPosition(), ccp(item->getContentSize().width / 2.8,
(item->getContentSize().height + 10) * (rankSize - i) - item->getContentSize().height - 30)));
finalLen += (item->getContentSize().height + 10);
}
}
m_scrollview->setContentOffset(ccp(0, -finalLen + m_scrollview->getContentSize().height - 10));
m_scrollview->setContentSize(CCSizeMake(350, finalLen));
m_scrollview->getContainer()->setContentSize(CCSizeMake(350, finalLen + 20));
SGButton *okButton = SGButton::createFromLocal("box_btnbg.png", str_Ok, this, menu_selector(SpRuleInfoBox::pressOkButton),
ccp(0, 0), FONT_PANGWA, ccWHITE, 24);
this->addBtn(okButton);
okButton->setPosition(ccpAdd(center, ccp(0, -324/2+5 -70)));
}
示例8: show
void ShowTip::show(const char *str, cocos2d::CCPoint& point, float fontSize, float delayTime, bool displayBg)
{
CCLabelTTF* ttfTip = CCLabelTTF::create(str, "宋体", fontSize);
ttfTip->cocos2d::CCNode::setAnchorPoint(CCPoint(0, 0));
CCSize size = ttfTip->getContentSize();
CCLayerColor* bgColor = NULL;
if (displayBg)
{
bgColor = CCLayerColor::create();
bgColor->setColor(ccColor3B(ccc3(0, 0, 0)));
bgColor->setAnchorPoint(CCPoint(0.5,0.5));
bgColor->setPosition(CCPoint(point.x - size.width * 0.5, point.y - 40));
bgColor->setContentSize(size);
bgColor->addChild(ttfTip);
this->addChild(bgColor);
ttfTip->setFontFillColor(ccColor3B(ccc3(255, 255, 255)));
}
else
{
size = CCSize(0,0);
ttfTip->setFontFillColor(ccColor3B(ccc3(0, 0, 0)));
ttfTip->setPosition(CCPoint(point.x, point.y - 60));
this->addChild(ttfTip);
}
CCAction* moveTo = CCMoveTo::create(delayTime, CCPoint(point.x - size.width * 0.5, point.y + 40));
if ( displayBg && bgColor )
{
CCFadeIn* fadeIn = CCFadeIn::create(delayTime * 0.25);
CCScaleTo* scaleTo = CCScaleTo::create(delayTime * 0.5, 1);
CCFadeOut* fadeOut = CCFadeOut::create(delayTime * 0.25);
bgColor->runAction(CCSequence::create(fadeIn,scaleTo, fadeOut, NULL));
bgColor->runAction(moveTo);
}
else
{
CCFadeIn* fadeIn = CCFadeIn::create(delayTime * 0.5);
CCFadeOut* fadeOut = CCFadeOut::create(delayTime * 0.5);
ttfTip->runAction(CCSequence::create(fadeIn, fadeOut, NULL));
ttfTip->runAction(moveTo);
}
scheduleOnce(schedule_selector(ShowTip::removeFromParent), delayTime);
}
示例9:
CCLayer* CommonScrollBar2::createScrollContent(const CCSize& size) {
CCLayerColor* layer = CCLayerColor::create(ccc4(255, 0, 0, 255));
float y = 0;
char buf[64];
for(int i = 0; i < 100; i++) {
sprintf(buf, "test label %d", i);
CCLabelTTF* label = CCLabelTTF::create(buf, "Helvetica", 24);
label->setAnchorPoint(ccp(0, 0));
label->setPosition(ccp(0, y));
layer->addChild(label);
y += label->getContentSize().height + 10 / CC_CONTENT_SCALE_FACTOR();
}
layer->setContentSize(CCSizeMake(size.width, y));
return layer;
}
示例10: init
bool LoadingScene::init()
{
CCLayer::init();
const CCSize size = CCDirector::sharedDirector()->getWinSize();
CCLayerColor *background = CCLayerColor::create(ccc4(200, 200, 200, 255));
background->setContentSize(size);
addChild(background, -1);
CCLabelTTF *labelLoading = CCLabelTTF::create("Loading...", "Arial", 20);
labelLoading->setPosition(CCPoint(size.width * 0.5, size.height * 0.5));
addChild(labelLoading, 1);
labelLoading->setColor(ccBLACK);
scheduleUpdate();
return true;
}
示例11: init
// on "init" you need to initialize your instance
bool StageSelectScene::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
//사이즈 받아오기 (윈도우 사이즈)
//CCSize size = CCDirector::sharedDirector()->getWinSize();
//스크롤 뷰 및 페이지 컨트롤 설정
//스크롤 되는 메뉴 불러오기
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLayerColor* layer = CCLayerColor::create();
layer->setPosition(0, 0);
layer->setContentSize(CCSizeMake(s.width, 210));
for (int i = 0; i < 4; i++)
{
std::string str = "CloseNormal.png";
CCMenuItemImage* item = CCMenuItemImage::create(str.c_str(),
str.c_str(),
this,
menu_selector(StageSelectScene::menuCallbackBuyCharater));
item->setTag(i);
ScrollMenu* menu = ScrollMenu::create(item, NULL);
menu->setPosition(ccp(i * 100, 100));
layer->addChild(menu);
}
// Set up scroll view
cocos2d::extension::CCScrollView *scrollView = cocos2d::extension::CCScrollView::create(s, layer);
scrollView->setAnchorPoint(ccp(0,0));
scrollView->setPosition(ccp(0, 465));
scrollView->setDirection(cocos2d::extension::kCCScrollViewDirectionHorizontal);
this->addChild(scrollView);
return true;
}
示例12: createPauseLayer
void GameLayer::createPauseLayer() {
Context *context = Context::sharedContext();
CCSize s = CCDirector::sharedDirector()->getWinSize();
/* 半透明层 */
CCLayerColor* pauseLayer = CCLayerColor::create();
pauseLayer->setContentSize(CCSizeMake(s.width, s.height));
pauseLayer->setColor(ccc3(0, 0, 0));
pauseLayer->setOpacity(150);
CCMenu *menu = CCMenu::create();
//回到游戏
CCMenuItemImage *resumebg = CCMenuItemImage::create(("btn_big.png"),
("btn_big.png"));
resumebg->setTarget(this, menu_selector(GameLayer::onResumeItem));
CCMenuItemFont *resumetxt = CCMenuItemFont::create(LOCAL_RESOURCES->valueByKey("i18n_resume")->getCString());
resumebg->setAnchorPoint(ccp(0.5, 0.5));
resumebg->setPosition(ccpp(0, 0));
resumetxt->setPosition(
ccp(resumebg->getContentSize().width / 2,
resumebg->getContentSize().height / 2));
resumetxt->setAnchorPoint(ccp(0.5, 0.5));
resumetxt->setColor(context->getFontColor());
resumebg->addChild(resumetxt);
menu->addChild(resumebg);
//回到菜单
CCMenuItemImage *backbg = CCMenuItemImage::create(("btn_big.png"),
("btn_big.png"));
backbg->setTarget(this, menu_selector(GameLayer::onBackItem));
CCMenuItemFont *backtxt = CCMenuItemFont::create(LOCAL_RESOURCES->valueByKey("i18n_back")->getCString());
backbg->setAnchorPoint(ccp(0.5, 0.5));
backbg->setPosition(ccpp(0, -0.12));
backtxt->setPosition(
ccp(backbg->getContentSize().width / 2,
backbg->getContentSize().height / 2));
backtxt->setAnchorPoint(ccp(0.5, 0.5));
backtxt->setColor(context->getFontColor());
backbg->addChild(backtxt);
menu->addChild(backbg);
pauseLayer->addChild(menu);
CCDirector::sharedDirector()->getRunningScene()->addChild(pauseLayer, 0,
TAG_LAYER_PAUSE);
}
示例13: handler_method_fill
int Bitmap::handler_method_fill( int ptr1, void* ptr2 )
{
FillRectStruct* ptr2str = (FillRectStruct*)ptr2;
Bitmap* bitmap =(Bitmap*)ptr1;
if (NULL!=bitmap->p->m_emuBitmap)
{
Vec4 color = ptr2str->color;
CCLayerColor* layerColor = CCLayerColor::create(ccc4(color.x*255,color.y*255,color.z*255,color.w*255));
layerColor->setContentSize(CCSizeMake(ptr2str->rect.w,ptr2str->rect.h));
layerColor->setAnchorPoint(ccp(0,1));
layerColor->ignoreAnchorPointForPosition(false);
layerColor->setPosition(ccp(ptr2str->rect.x,rgss_y_to_cocos_y(ptr2str->rect.y,bitmap->p->m_height)));
bitmap->p->m_emuBitmap->addChild(layerColor);
}
delete ptr2str;
return 0;
}
示例14: init
bool BillboardScene::init()
{
bool bRef = false;
do{
CC_BREAK_IF(!CCLayer::init());
this->setContentSize(CCSizeZero);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCLayerColor* layerColor = CCLayerColor::create();
layerColor->setColor(ccc3(0, 0, 0));
layerColor->setOpacity(150);
layerColor->setContentSize(CCSizeMake(winSize.width, winSize.height));
this->addChild(layerColor,0);
setTouchEnabled(true);
bRef = true;
}while(0);
return bRef;
}
示例15: setTouchEnabled
// on "init" you need to initialize your instance
bool Bug914Layer::init()
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super" return value
if (BugsTestBaseLayer::init())
{
setTouchEnabled(true);
// ask director the the window size
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCLayerColor *layer;
for( int i=0;i < 5;i++)
{
layer = CCLayerColor::create(ccc4(i*20, i*20, i*20,255));
layer->setContentSize(CCSizeMake(i*100, i*100));
layer->setPosition(ccp(size.width/2, size.height/2));
layer->setAnchorPoint(ccp(0.5f, 0.5f));
layer->setIsRelativeAnchorPoint(true);
addChild(layer, -1-i);
}
// create and initialize a Label
CCLabelTTF *label = CCLabelTTF::create("Hello World", "Marker Felt", 64);
CCMenuItem *item1 = CCMenuItemFont::create("restart", this, menu_selector(Bug914Layer::restart));
CCMenu *menu = CCMenu::create(item1, NULL);
menu->alignItemsVertically();
menu->setPosition(ccp(size.width/2, 100));
addChild(menu);
// position the label on the center of the screen
label->setPosition(ccp( size.width /2 , size.height/2 ));
// add the label as a child to this Layer
addChild(label);
return true;
}
return false;
}