本文整理汇总了C++中CCLayerColor::ignoreAnchorPointForPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayerColor::ignoreAnchorPointForPosition方法的具体用法?C++ CCLayerColor::ignoreAnchorPointForPosition怎么用?C++ CCLayerColor::ignoreAnchorPointForPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLayerColor
的用法示例。
在下文中一共展示了CCLayerColor::ignoreAnchorPointForPosition方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showFont
void FontTest::showFont(const char *pFont)
{
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCSize blockSize = CCSizeMake(s.width/3, 200);
float fontSize = 26;
removeChildByTag(kTagLabel1, true);
removeChildByTag(kTagLabel2, true);
removeChildByTag(kTagLabel3, true);
removeChildByTag(kTagLabel4, true);
CCLabelTTF *top = CCLabelTTF::create(pFont, pFont, 24);
CCLabelTTF *left = CCLabelTTF::create("alignment left", pFont, fontSize,
blockSize, kCCTextAlignmentLeft, verticalAlignment[vAlignIdx]);
CCLabelTTF *center = CCLabelTTF::create("alignment center", pFont, fontSize,
blockSize, kCCTextAlignmentCenter, verticalAlignment[vAlignIdx]);
CCLabelTTF *right = CCLabelTTF::create("alignment right", pFont, fontSize,
blockSize, kCCTextAlignmentRight, verticalAlignment[vAlignIdx]);
CCLayerColor *leftColor = CCLayerColor::create(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height);
CCLayerColor *centerColor = CCLayerColor::create(ccc4(200, 100, 100, 255), blockSize.width, blockSize.height);
CCLayerColor *rightColor = CCLayerColor::create(ccc4(100, 100, 200, 255), blockSize.width, blockSize.height);
leftColor->ignoreAnchorPointForPosition(false);
centerColor->ignoreAnchorPointForPosition(false);
rightColor->ignoreAnchorPointForPosition(false);
top->setAnchorPoint(ccp(0.5, 1));
left->setAnchorPoint(ccp(0,0.5));
leftColor->setAnchorPoint(ccp(0,0.5));
center->setAnchorPoint(ccp(0,0.5));
centerColor->setAnchorPoint(ccp(0,0.5));
right->setAnchorPoint(ccp(0,0.5));
rightColor->setAnchorPoint(ccp(0,0.5));
top->setPosition(ccp(s.width/2,s.height-20));
left->setPosition(ccp(0,s.height/2));
leftColor->setPosition(left->getPosition());
center->setPosition(ccp(blockSize.width, s.height/2));
centerColor->setPosition(center->getPosition());
right->setPosition(ccp(blockSize.width*2, s.height/2));
rightColor->setPosition(right->getPosition());
this->addChild(leftColor, -1);
this->addChild(left, 0, kTagLabel1);
this->addChild(rightColor, -1);
this->addChild(right, 0, kTagLabel2);
this->addChild(centerColor, -1);
this->addChild(center, 0, kTagLabel3);
this->addChild(top, 0, kTagLabel4);
}
示例2: init
bool StatusMenu::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLayerColor* layer = CCLayerColor::create( ccc4(135, 135 , 135, 255));
layer->ignoreAnchorPointForPosition(false);
layer->setPosition( CCPointMake(s.width/2, s.height/2) );
addChild(layer, 0);
CCMenuItemImage *closebutton = CCMenuItemImage::create("close.png", "close_down.png", this, menu_selector(StatusMenu::CloseCallback));
CCMenuItemImage *itembutton = CCMenuItemImage::create("package.png", "package_down.png", this, menu_selector(StatusMenu::ItemMenuCallback));
CCMenuItemImage *charabutton = CCMenuItemImage::create("chara.png", "chara_down.png", this, menu_selector(StatusMenu::CharacterMenuCallback));
closebutton->setPosition(ccp(-250, 50));
itembutton->setPosition(ccp(-250, 105));
charabutton->setPosition(ccp(-250, 160));
CCMenu *menu = CCMenu::create(charabutton,itembutton,closebutton,NULL);
addChild(menu,1);
CCSprite *charabox = CCSprite::create("menu_bg_all.png");
charabox->setPosition(ccp(450, s.height/2));
addChild(charabox,1,12);
CCSprite *itembox = CCSprite::create("item_bg_all.png");
itembox->setPosition(ccp(450, s.height/2));
addChild(itembox,1,13);
CCMenu *itemmenu = CCMenu::create();
for (int i=0; i<player->items.size(); i++) {
switch (player->items[i]) {
case 4:{
CCMenuItemLabel *item = CCMenuItemLabel::create(CCLabelTTF::create("手电筒 X1", "AR PLMingU20 Light", 24));
itemmenu->addChild(item, i+1, i+1);
break;
}
case 6:{
CCMenuItemLabel *item = CCMenuItemLabel::create(CCLabelTTF::create("水果刀 X1", "AR PLMingU20 Light", 24));
itemmenu->addChild(item, i+1, i+1);
break;
}
case 12:{
CCMenuItemLabel *item = CCMenuItemLabel::create(CCLabelTTF::create("钥匙 X1", "AR PLMingU20 Light", 24));
itemmenu->addChild(item, i+1, i+1);
break;
}
default:
break;
}
}
itemmenu->setAnchorPoint(ccp(0, 1));
itemmenu->alignItemsVertically();
itemmenu->setPosition(itembox->getPositionX()-300,itembox->getPositionY()+130);
itembox->addChild(itemmenu);
CharacterMenuCallback(NULL);
return true;
}
示例3: setTouchEnabled
//------------------------------------------------------------------
//
// LayerTest1
//
//------------------------------------------------------------------
void LayerTest1::onEnter()
{
LayerTest::onEnter();
setTouchEnabled(true);
CCSize s = CCDirector::sharedDirector()->getWinSize();
CCLayerColor* layer = CCLayerColor::create( ccc4(0xFF, 0x00, 0x00, 0x80), 200, 200);
layer->ignoreAnchorPointForPosition(false);
layer->setPosition( ccp(s.width/2, s.height/2) );
addChild(layer, 1, kTagLayer);
}
示例4: initView
//初始化视图
void SGFateInfoLayer::initView()
{
tableViewHeight = 210 * 1;
ResourceManager::sharedInstance()->bindTexture("sggeneralinfolayer/ofcNewUi.plist", RES_TYPE_LAYER_UI, sg_generalInfoLayer);
ResourceManager::sharedInstance()->bindTexture("tran/tran.plist", RES_TYPE_LAYER_UI, sg_generalInfoLayer);
ResourceManager::sharedInstance()->bindTexture("ofc_frame_new/ofc_frame_new.plist", RES_TYPE_LAYER_UI, sg_generalInfoLayer);
CCPoint center = SGLayout::getPoint(kMiddleCenter);
//灰图
CCLayerColor* layer = CCLayerColor::create(ccc4(0, 0, 0, 180), skewing(520)*3, skewingY(960)*3);
layer->ignoreAnchorPointForPosition(false);
layer->setPosition(center);
this->addChild(layer, -10);
//背景
CCSprite* bg = CCSprite::createWithSpriteFrameName("ofc_bkg.png");
bg->setPosition( center );
this->addChild(bg, -8);
CCSize size = bg->getContentSize();
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
//标题缘分列表
CCSprite* title = CCSprite::createWithSpriteFrameName("ofc_title_yflb.png");
title->setPosition(ccpAdd( center,ccp(0, size.height * 0.5 - title->getContentSize().height * 0.5 -15) ));
this->addChild(title, -7);
//确定按钮
SGButton *confirm = SGButton::create("box_btn_newbg.png", "public_font_queding.png", this, menu_selector(SGFateInfoLayer::confirmHandler), ccp(0, 0), false, true);
confirm->setPosition (ccpAdd(center,ccp(0, - size.height * 0.45)));
this->addBtn(confirm);
//显示区域
tableView->setFrame(CCRectMake(0, 0, winSize.width * 2, (size.height - title->getContentSize().height - confirm->getContentSize().height - 10) * 1 ));
tableView->setDown(-130);
//tableView->setDown(0);
tableView->setPosition(ccp(-winSize.width, (winSize.height - size.height) * 0.5 + confirm->getContentSize().height ));
setTouchPad(false);
/////////////弹出效果
this->setScale(.3);
CCScaleTo *scale1=CCScaleTo::create(0.1,1.1);
CCScaleTo *scale3=CCScaleTo::create(0.1,1.05);
CCSequence*action=CCSequence::create(scale1,scale3,NULL);
this->runAction(action);
}
示例5: 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;
}
示例6: init
// on "init" you need to initialize your instance
bool GameScene::init()
{
if ( !CCLayer::init() )
{
return false;
}
// Variables de tamanyo
CCSize vs = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
// Layer con los botones al hacer pause
_layerPause = CCLayerColor::create(ccc4(255,255,255,0));
_layerPause->setContentSize(CCSizeMake(350, 100));
_layerPause->ignoreAnchorPointForPosition(false);
_layerPause->setAnchorPoint(ccp(0.5, 0.5));
_layerPause->setPosition(ccp(vs.width/2, vs.height/2));
_layerPause->retain();
CCMenuItem* button_resume = CCMenuItemImage::create("btn_resume.png", "btn_resume_h.png", this, menu_selector(GameScene::menuResumeCallback));
button_resume->setPosition(ccp(50, 50));
CCMenuItem* button_restart = CCMenuItemImage::create("btn_restart.png", "btn_restart_h.png", this, menu_selector(GameScene::menuRestartCallback));
button_restart->setPosition(ccp(175, 50));
CCMenuItem* button_exit = CCMenuItemImage::create("btn_exit.png", "btn_exit_h.png", this, menu_selector(GameScene::menuExitCallback));
button_exit->setPosition(ccp(300, 50));
CCMenu* menu_pause = CCMenu::create(button_resume, button_restart, button_exit, NULL);
menu_pause->setPosition(ccp(0,0));
_layerPause->addChild(menu_pause);
// Layer que se muestra al terminar la carrera
_layerEnd = CCLayerColor::create(ccc4(0,0,0,0));
_layerEnd->setContentSize(CCSizeMake(225, 225));
_layerEnd->ignoreAnchorPointForPosition(false);
_layerEnd->setAnchorPoint(ccp(0.5, 0.5));
_layerEnd->setPosition(ccp(vs.width/2, vs.height/2));
_layerEnd->retain();
CCMenuItem* button_end_restart = CCMenuItemImage::create("btn_restart.png", "btn_restart_h.png", this, menu_selector(GameScene::menuRestartCallback));
button_end_restart->setPosition(ccp(50, 50));
CCMenuItem* button_end_exit = CCMenuItemImage::create("btn_exit.png", "btn_exit_h.png", this, menu_selector(GameScene::menuExitCallback));
button_end_exit->setPosition(ccp(175, 50));
CCMenu* menu_end = CCMenu::create(button_end_restart, button_end_exit, NULL);
menu_end->setPosition(ccp(0,0));
CCLayerColor* layerTime = CCLayerColor::create(ccc4(255,255,255,255));
layerTime->setContentSize(CCSizeMake(225, 100));
layerTime->ignoreAnchorPointForPosition(false);
layerTime->setAnchorPoint(ccp(0.5, 0.5));
layerTime->setPosition(ccp(112.5, 175));
layerTime->retain();
_labelTimeEnd = CCLabelTTF::create("Time:\n0:00:000", "fonts/FrancoisOne.ttf", 30, CCSizeMake(225, 100), kCCTextAlignmentCenter);
_labelTimeEnd->setColor(ccc3(0,0,0));
_labelTimeEnd->setPosition(ccp(112.5, 50));
layerTime->addChild(_labelTimeEnd);
_layerEnd->addChild(menu_end);
_layerEnd->addChild(layerTime);
// Boton de pause (menu)
CCMenuItem* button_pause = CCMenuItemImage::create("btn_pause.png", "btn_pause_h.png", this, menu_selector(GameScene::menuPauseCallback));
button_pause->setPosition(ccp(75, vs.height - 75));
CCMenu* menu = CCMenu::create(button_pause, NULL);
menu->setPosition(ccp(0,0));
// Velocidad
CCString* stringVel = CCString::createWithFormat("%d km/h", (int)_vel);
_labelVel = CCLabelTTF::create(stringVel->getCString(), "fonts/FrancoisOne.ttf", 30, CCSizeMake(140, 50), kCCTextAlignmentCenter);
_labelVel->setColor(ccc3(255,255,255));
_labelVel->setPosition(ccp(vs.width - 72, 50));
// Distancia
CCString* stringDist = CCString::createWithFormat("%d m", (int)_dist);
_labelDist = CCLabelTTF::create(stringDist->getCString(), "fonts/FrancoisOne.ttf", 30, CCSizeMake(140, 50), kCCTextAlignmentCenter);
_labelDist->setColor(ccc3(255,255,255));
_labelDist->setPosition(ccp(72, 50));
// Tiempo
int hs = _time/3600000;
int mins = (_time%3600000)/60000;
int ss = ((_time%3600000)%60000)/1000;
int ms = ((_time%3600000)%60000)%1000;
CCString* stringTime = CCString::createWithFormat("%d:%02d:%03d", mins, ss, ms);
_labelTime = CCLabelTTF::create(stringTime->getCString(), "fonts/FrancoisOne.ttf", 30, CCSizeMake(140, 50), kCCTextAlignmentCenter);
_labelTime->setColor(ccc3(255,255,255));
_labelTime->setPosition(ccp(vs.width - 72, vs.height - 50));
// Click to start
_labelStart = CCLabelTTF::create("Click to Start", "fonts/FrancoisOne.ttf", 50, CCSizeMake(200, 200), kCCTextAlignmentCenter);
_labelStart->setColor(ccc3(255,255,255));
_labelStart->setPosition(ccp(vs.width/2, vs.height/2));
_labelStart->retain();
// Hierba
//.........这里部分代码省略.........
示例7: init
// on "init" you need to initialize your instance
bool MainMenuScene::init()
{
// Parent
CCLayerColor *layer = CCLayerColor::create();
layer->initWithColor(ccc4(255, 255, 255, 255), VisibleRect::right().x , VisibleRect::top().y);
layer->setPosition(VisibleRect::center());
layer->setAnchorPoint(ccp(0.5f, 0.5f));
layer->ignoreAnchorPointForPosition(false);
addChild(layer, 0);
CCSprite *fondo = CCSprite::create("fondo.png");
fondo->setPosition(VisibleRect::center());
layer->addChild(fondo);
// 1st Son
CCLayerColor *upperLayer = CCLayerColor::create();
upperLayer->setContentSize(ccp(VisibleRect::right().x , VisibleRect::top().y/2));
//upperLayer->initWithColor(ccc4(120, 120, 120, 120), VisibleRect::right().x , VisibleRect::top().y/2);
upperLayer->setPosition(ccp(VisibleRect::left().x, VisibleRect::center().y));
upperLayer->setAnchorPoint(ccp(0,0));
upperLayer->ignoreAnchorPointForPosition(false);
layer->addChild(upperLayer, 0);
CCSprite *spriteLogo = CCSprite::create("logo_opciones.png");
spriteLogo->setPosition(ccp(layer->getPosition().x, layer->getPosition().y/2));
upperLayer->addChild(spriteLogo);
// 2nd Son
CCLayerColor *lowerLayer = CCLayerColor::create();
lowerLayer->setContentSize(ccp(VisibleRect::right().x , VisibleRect::top().y/2));
//lowerLayer->initWithColor(ccc4(200, 200, 200, 200), VisibleRect::right().x , VisibleRect::top().y/2);
lowerLayer->setPosition(ccp(VisibleRect::left().x, VisibleRect::bottom().y));
lowerLayer->setAnchorPoint(ccp(0,0));
lowerLayer->ignoreAnchorPointForPosition(false);
layer->addChild(lowerLayer, 0);
int mySize = lowerLayer->getContentSize().height / 3;
// Button SAILKAPENA
CCTexture2D *texture1 = CCTextureCache::sharedTextureCache()->addImage("botoia_normal.png");
SpriteButton *pButton1 = SpriteButton::create(texture1 ,this, callfuncO_selector(MainMenuScene::menuSelector), 1.0f);
pButton1->setTag(2);
pButton1->setPosition(ccp(
lowerLayer->getContentSize().width / 2,
lowerLayer->getContentSize().height / 2));
pButton1->setAnchorPoint(ccp(0.5f, 0.5f));
CCLabelTTF *pLabel1 = CCLabelTTF::create("Sailkapena", "fonts/PT_Sans-Web-Bold.ttf", 30.0);
pLabel1->setPosition(ccp(
lowerLayer->getContentSize().width / 2,
lowerLayer->getContentSize().height / 2));
lowerLayer->addChild(pButton1);
lowerLayer->addChild(pLabel1);
// Button JOKATU
CCTexture2D *texture2 = CCTextureCache::sharedTextureCache()->addImage("botoia_normal.png");
SpriteButton *pButton2 = SpriteButton::create(texture2 ,this, callfuncO_selector(MainMenuScene::menuSelector), 1.0f);
pButton2->setTag(1);
pButton2->setPosition(ccp(
lowerLayer->getContentSize().width / 2,
(mySize * 3) - texture2->getContentSize().height));
pButton2->setAnchorPoint(ccp(0.5f, 0.5f));
CCLabelTTF *pLabel2 = CCLabelTTF::create("Jokatu", "fonts/PT_Sans-Web-Bold.ttf", 30.0);
pLabel2->setPosition(ccp(
lowerLayer->getContentSize().width / 2,
(mySize * 3) - texture2->getContentSize().height));
lowerLayer->addChild(pButton2);
lowerLayer->addChild(pLabel2);
// Button HONI BURUZ
CCTexture2D *texture3 = CCTextureCache::sharedTextureCache()->addImage("botoia_normal.png");
SpriteButton *pButton3 = SpriteButton::create(texture3 ,this, callfuncO_selector(MainMenuScene::menuSelector), 1.0f);
pButton3->setTag(3);
pButton3->setPosition(ccp(
lowerLayer->getContentSize().width / 2,
mySize - (texture2->getContentSize().height / 2)));
pButton3->setAnchorPoint(ccp(0.5f, 0.5f));
CCLabelTTF *pLabel3 = CCLabelTTF::create("Honi buruz", "fonts/PT_Sans-Web-Bold.ttf", 30.0);
pLabel3->setPosition(ccp(
lowerLayer->getContentSize().width / 2,
mySize - (texture2->getContentSize().height / 2)));
lowerLayer->addChild(pButton3);
lowerLayer->addChild(pLabel3);
return true;
}
示例8: constructView
void SGCGMovieLayer::constructView()
{
SGNotificationCenter::sharedNotificationCenter()->addObserver(MSG_CGBATTLE_START, this, callfuncO_selector(SGCGMovieLayer::cgBattleListener));
s = CCDirector::sharedDirector()->getWinSize();
ResourceManager::sharedInstance()->bindTexture("bg/cgBg.plist", RES_TYPE_LAYER_UI, sg_cgMovieLayer);
CCSprite *cgBg = CCSprite::createWithSpriteFrameName("cgBg.png");
cgBg->setAnchorPoint(ccp(0.5, 1));
cgBg->ignoreAnchorPointForPosition(false);
cgBg->cocos2d::CCNode::setScaleX(s.width/cgBg->getContentSize().width);
cgBg->setPosition(ccp(s.width/2, s.height));
addChild(cgBg);
// SGButton *skipBt = SGButton::createFromLocal("box_btnbg.png", "跳 过", this, menu_selector(SGCGMovieLayer::cgSkipToBattle), CCPointZero, FONT_PANGWA,ccWHITE,32,false,true);
// skipBt->setPosition(ccp(s.width/2, skipBt->getContentSize().height*2));
// addBtn(skipBt);
CCLayerColor * blackBg = CCLayerColor::create(ccc4(0, 0, 0, 255), s.width, s.height);
blackBg->setTouchEnabled(false);
blackBg->ignoreAnchorPointForPosition(false);
blackBg->setAnchorPoint(ccp(0, 0));
blackBg->setPosition(ccp(0, 0));
this->addChild(blackBg, -100);
scrollRect = CCRectMake(0, s.height*0.2, s.width, s.height/4);
cgScrollView = SNSScrollView::create(scrollRect);
cgScrollView->setFrame(scrollRect);
cgScrollView->setPosition(scrollRect.origin);
cgScrollView->setHorizontal(false);
cgScrollView->setVertical(true);
cgScrollView->setTouchEnabled(false);
this->addChild(cgScrollView);
// CCSprite *scrollBg = CCSprite::createWithSpriteFrameName("barrack_kuang.png");
// scrollBg->cocos2d::CCNode::setScale(s.width/scrollBg->getContentSize().width, s.height/4/scrollBg->getContentSize().height);
// scrollBg->setPosition(ccpAdd(scrollRect.origin, ccp(s.width/2, s.height/8)));
// addChild(scrollBg);
char *spritData = new char[(int)s.width * (int)s.height *4];
memset(spritData,0,(int)s.width * (int)s.height *4);
int spriteDataSize = (int)s.width * (int)s.height*4;
for (int j=0; j<spriteDataSize; j+=4) {
spritData[j] = 0;
spritData[j+1] = 0;
spritData[j+2] = 0;
spritData[j+3] = 255;
}
CCTexture2D *pTexture = new CCTexture2D();
pTexture->initWithData(spritData, kCCTexture2DPixelFormat_Default, (int)s.width, (int)s.height, s);
finaleSprite = CCSprite::createWithTexture(pTexture);
finaleSprite->setPosition(CCPointZero);
finaleSprite->setAnchorPoint(CCPointZero);
this->addChild(finaleSprite,10,10);
finaleSprite->setVisible(false);
finaleSprite->setOpacity(0);
delete [] spritData;
pTexture->autorelease();
this->setTouchEnabled(true);
const char *str[7] = { str_CGMovieLayer_str1,
str_CGMovieLayer_str2,
str_CGMovieLayer_str3,
str_CGMovieLayer_str4,
str_CGMovieLayer_str5,
str_CGMovieLayer_str6,
str_CGMovieLayer_str7};
SGCCLabelTTF *cgMsg = NULL;
posY = -20;
for (int i=0; i<7; i++) {
cgMsg = SGCCLabelTTF::create(str[i], FONT_BOXINFO, 34);
cgMsg->cocos2d::CCNode::setPosition(s.width/2, posY);
cgScrollView->m_body->addChild(cgMsg);
posY -= 50;
}
moveCgMsgDis = CGMSGMOVEDIS;
unschedule(schedule_selector(SGCGMovieLayer::moveCgMsgUp));
if (SGPlayerInfo::sharePlayerInfo()->getCDKeyNeed()==1) {
SGNotificationCenter::sharedNotificationCenter()->addObserver(MSG_CDK, this, callfuncO_selector(SGCGMovieLayer::cdkListener));
ResourceManager::sharedInstance()->bindTexture("sgloginingbox/sgloginingbox.plist", RES_TYPE_LAYER_UI, sg_cgMovieLayer);
// ResourceManager::sharedInstance()->bindTexture("sgserverlistlayer/sgserverlistlayer.plist",RES_TYPE_LAYER_UI ,sg_registerLayer);
box = CCSprite::createWithSpriteFrameName("register_diban.png");
box->setPosition(SGLayout::getPoint(kMiddleCenter));
this->addChild(box);
m_cdk = CCEditBox::create(CCSizeMake(500, 60), CCScale9Sprite::createWithSpriteFrameName("public_kuang_input.png"));
m_cdk->setPlaceHolder(str_CGMovieLayer_str8);
m_cdk->setPlaceholderFontColor(ccc3(0x82,0x3e,0x02));
m_cdk->setMaxLength(10);
m_cdk->setReturnType(kKeyboardReturnTypeDone);
//.........这里部分代码省略.........
示例9: 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的内容体偏移
//.........这里部分代码省略.........