本文整理汇总了C++中CCLayerColor::getPositionY方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayerColor::getPositionY方法的具体用法?C++ CCLayerColor::getPositionY怎么用?C++ CCLayerColor::getPositionY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLayerColor
的用法示例。
在下文中一共展示了CCLayerColor::getPositionY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool NovelScene::init()
{
if (!CCLayer::init())
{
return false;
}
this->setTouchEnabled(true);
this->setTouchMode(kCCTouchesOneByOne);
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCSprite* background = CCSprite::create("013-PostTown01.jpg");
background->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.5));
this->addChild(background, kZOrder_Background, kTag_Background);
CCLayerColor * textLayer = CCLayerColor::create(ccc4(0, 0, 0, 255 * 0.7), winSize.width, winSize.height * 0.25);
textLayer->setPosition(CCPointZero);
this->addChild(textLayer, kZOrder_TextLayer, kTag_TextLayer);
CCString* string = CCString::createWithFormat("w = %f.1 h = %f.1 f = %f", winSize.width, winSize.height, BASE_FONT_SIZE);
CCLog("%s", string->getCString());
CCLabelTTF* textLabel = CCLabelTTF::create(string->getCString(), "", BASE_FONT_SIZE);
textLabel->setAnchorPoint(ccp(0, 0));
textLabel->setColor(ccWHITE);
textLabel->setPosition(ccp(BASE_FONT_SIZE, textLayer->getContentSize().height - textLabel->getContentSize().height - BASE_FONT_SIZE));
textLayer->addChild(textLabel, kZOrder_TextLayer, kTag_TextLayer_textLabel);
CCLayerColor * nameTextLayer = CCLayerColor::create(ccc4(0, 0, 0, 255 * 0.7), winSize.width * 0.4, winSize.height * 0.1);
nameTextLayer->setPosition(ccp(textLayer->getPositionX(), textLayer->getPositionY() + textLayer->getContentSize().height + nameTextLayer->getContentSize().height * 0.05));
this->addChild(nameTextLayer, kZOrder_TextLayer, kTag_TextLayer_name);
CCLabelTTF* nameTextLabel = CCLabelTTF::create("시스템 메세지", "", BASE_FONT_SIZE);
nameTextLabel->setAnchorPoint(ccp(0, 0));
nameTextLabel->setColor(ccGREEN);
nameTextLabel->setPosition(ccp(BASE_FONT_SIZE, nameTextLayer->getContentSize().height - nameTextLabel->getContentSize().height - BASE_FONT_SIZE * 0.5));
nameTextLayer->addChild(nameTextLabel, kZOrder_TextLayer, kTag_TextLayer_nameTextLabel);
CCLabelTTF* logButtonLabel = CCLabelTTF::create("Log", "Arial", BASE_FONT_SIZE);
CCMenuItemLabel* logButtonMenuItem = CCMenuItemLabel::create(logButtonLabel, this, menu_selector(NovelScene::logMenuSelectCallback));
logButtonMenuItem->setPosition(ccp(winSize.width * 0.95, logButtonMenuItem->getContentSize().height));
CCMenu* pMenu = CCMenu::create(logButtonMenuItem, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, kZOrder_MenuItem, kTag_MenuItem_log);
return true;
}
示例2: 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的内容体偏移
//.........这里部分代码省略.........