// on "init" you need to initialize your instance bool S11PrepareRes::init() { ////////////////////////////// // 1. super init first if ( !CCLayer::init() ) { return false; } //每个项目都要创建的东西 _menu = CCMenu::create(NULL); _menu->setPosition(CCPointZero); this->addChild(_menu, 101); titleString = ""; scriptMap=ScriptParser::paserScript("S11PrepareRes","leftTitle");//right_TableView_Map //背景图 { CCSprite * aSprite = CCSprite::create("s11Background.png"); aSprite->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2)); //CC_BREAK_IF(! aSprite); this->addChild(aSprite,98); aSprite ->getTexture()->setAntiAliasTexParameters();//抗锯齿 } //控件 { CCSprite * aSprite = CCSprite::create("s11NavBar.png"); aSprite->setAnchorPoint(ccp(0.0,1.0)); aSprite->setPosition(ccp(0,visibleSize.height-40)); this->addChild(aSprite,100); } { CCLabelTTF * leftTitleLabel = CCLabelTTF::create(s11Str2_macro,s11FontName_macro,s11TitleFontSize_macro); CCLabelTTF* pLabel = leftTitleLabel; pLabel->setColor(ccWHITE); pLabel->setPosition( s11Position3_macro(pLabel)); this->addChild(pLabel, 100); } titleLabel = CCLabelTTF::create(s11Str2_macro,s11FontName_macro,s11TitleFontSize_macro); CCLabelTTF* pLabel = titleLabel; pLabel->setColor(ccWHITE); pLabel->setPosition( s11Position4_macro(pLabel)); this->addChild(pLabel, 100); { CCSprite * aSprite = CCSprite::create("pRecButton.png"); aSprite->setPosition(s11Position1_macro(aSprite)); this->addChild(aSprite,100); CCSprite * aSprite1 = CCSprite::create("s11FullScreenIcon.png"); aSprite1->setPosition(s11Position1_macro(aItem)); this->addChild(aSprite1,100); CCSprite * sprite1 = CCSprite::create(); CCSprite * sprite2 = CCSprite::create(); CCMenuItemSprite *aItem = CCMenuItemSprite::create( sprite1, sprite2, this, menu_selector(S11PrepareRes::menuCloseCallback)); aItem->setPosition(s11Position1_macro(aItem)); aItem->setContentSize(aSprite->getContentSize()); _menu ->addChild(aItem,100); } CCTableView * tableView = CCTableView::create(this, s11Size1_macro); tableView->setAnchorPoint(ccp(0.0,0.0)); tableView->setDirection(kCCScrollViewDirectionVertical); tableView->setPosition(s11Position8_macro(tableView)); tableView->setDelegate(this); tableView->setVerticalFillOrder(kCCTableViewFillTopDown); this->addChild(tableView,99); tableView->reloadData(); std::string aStr = ScriptParser::readScript("s11TableCellTxt1.txt"); S11PrepareRes::detailString = aStr; rightDetailTex = CCLabelTTF::create(aStr.c_str(), "Helvetica", 30.0); rightDetailTex->setColor(ccBLACK); rightDetailTex-> setDimensions(s11Size2_macro); rightDetailTex->setPosition(s11Position9_macro(label)); this->addChild(rightDetailTex,100); //TabelBar { pTabBar = CCSprite::create("pTabBar.png"); pTabBar->setAnchorPoint(ccp(0.0,1.0)); pTabBar->setPosition(CCPointZero); this->addChild(pTabBar,100); } m_highlightSp = CCSprite::create("pTabBarSelectedHighlight.png"); { m_practiceSprite = CCSprite::create("pPencilIcon.png"); CCSprite * aSprite = m_practiceSprite; aSprite->setPosition(s11Position5_macro(aSprite)); this->addChild(aSprite,100); CCSprite * sprite1 = CCSprite::create(); CCSprite * sprite2 = CCSprite::create(); m_practiceItem = CCMenuItemSprite::create( sprite1, sprite2, this, menu_selector(S11PrepareRes::menuselect)); CCMenuItemSprite *aItem = m_practiceItem ; aItem->setTag(2); aItem->setPosition(s11Position5_macro(aItem)); aItem->setContentSize(m_highlightSp->getContentSize()); _menu ->addChild(aItem,100); m_touchedItem = m_practiceItem; m_practiceLabel = CCLabelTTF::create(s11Str1_macro,s11FontName_macro,s11FontSize_macro); CCLabelTTF* pLabel = m_practiceLabel; pLabel->setColor(s11White_macro); pLabel->setAnchorPoint(ccp(0.5,1.0)); pLabel->setPosition( ccp(aItem->getPosition().x,aItem->getPosition().y-aItem->getContentSize().height/2+11)); this->addChild(pLabel, 100); } { m_prepareSprite = CCSprite::create("pDocumentIconActive.png"); CCSprite * aSprite = m_prepareSprite; aSprite->setPosition(s11Position6_macro(aSprite)); this->addChild(aSprite,100); CCSprite * sprite1 = CCSprite::create(); CCSprite * sprite2 = CCSprite::create(); m_prepareItem = CCMenuItemSprite::create( sprite1, sprite2, this, menu_selector(S11PrepareRes::menuselect)); CCMenuItemSprite *aItem = m_prepareItem ; aItem->setTag(3); aItem->setPosition(s11Position6_macro(aItem)); aItem->setContentSize(m_highlightSp->getContentSize()); _menu ->addChild(aItem,100); m_prepareLabel = CCLabelTTF::create(s11Str2_macro,s11FontName_macro,s11FontSize_macro); CCLabelTTF* pLabel = m_prepareLabel; pLabel->setColor(s11Blue_macro); pLabel->setAnchorPoint(ccp(0.5,1.0)); pLabel->setPosition( ccp(aItem->getPosition().x,aItem->getPosition().y-aItem->getContentSize().height/2+11) ); this->addChild(pLabel, 100); } { m_settingSprite = CCSprite::create("pSettingsIcon.png"); CCSprite * aSprite = m_settingSprite; aSprite->setPosition(s11Position7_macro(aSprite)); this->addChild(aSprite,100); CCSprite * sprite1 = CCSprite::create(); CCSprite * sprite2 = CCSprite::create(); m_setting = CCMenuItemSprite::create( sprite1, sprite2, this, menu_selector(S11PrepareRes::menuselect)); CCMenuItemSprite *aItem = m_setting ; aItem->setTag(5); aItem->setPosition(s11Position7_macro(aItem)); aItem->setContentSize(m_highlightSp->getContentSize()); _menu ->addChild(aItem,100); m_settingLabel= CCLabelTTF::create(s11Str3_macro,s11FontName_macro,s11FontSize_macro); CCLabelTTF* pLabel = m_settingLabel; pLabel->setColor(s11Blue_macro); pLabel->setAnchorPoint(ccp(0.5,1.0)); pLabel->setPosition( ccp(aItem->getPosition().x,aItem->getPosition().y-aItem->getContentSize().height/2+11) ); this->addChild(pLabel, 100); } m_highlightSp->setPosition(ccp(m_prepareSprite->getPosition().x,pTabBar->getPosition().y+pTabBar->getContentSize().height/2)); this->addChild(m_highlightSp,100); m_highlightSp->setColor(ccc3(200, 200, 200)); return true; }
bool S4HeZuo::setUpSubClass() { bool bRet = false; do { float firstStrFontSize = ScriptParser::getFontSizeFromPlist(plistDic,"firstTitle"); CCLabelTTF *firstTitleLabel = CCLabelTTF::create(ScriptParser::getStringFromPlist(plistDic,"firstTitle"), s1FontName_macro, firstStrFontSize); firstTitleLabel->setColor(ccc3(193.0,159.0,113.0)); firstTitleLabel->setPosition(ScriptParser::getPositionFromPlist(plistDic,"firstTitle")); this->addChild(firstTitleLabel,zNum+1); CCSprite * S1PSubBottomSprite = CCSprite::create("S1PSubBottom.png"); S1PSubBottomSprite->setPosition( ccp(origin.x+visibleSize.width/2,firstTitleLabel->getPosition().y-firstTitleLabel->getContentSize().height/2-10)); this->addChild(S1PSubBottomSprite,zNum); map<string, string> naviGroupStrMap = ScriptParser::getGroupStringFromPlist(plistDic,"naviTitle"); float naviFontSize = ScriptParser::getFontSizeFromPlist(plistDic,"naviTitle"); CCPoint naviStrPosition = ScriptParser::getPositionFromPlist(plistDic,"naviTitle"); for (int i=0; i<(int)naviGroupStrMap.size(); i++) { const char * labelStr = naviGroupStrMap[PersonalApi::convertIntToString(i+1)].c_str(); CCLabelTTF *pLabel = CCLabelTTF::create(labelStr, s1FontName_macro, naviFontSize); pLabel->setPosition(ccp(naviStrPosition.x+(pLabel->getContentSize().width+20)*i,naviStrPosition.y)); pLabel->setColor(ccc3(128.0,128.0,128.0)); this->addChild(pLabel,zNum+1); if ( AppDelegate::S4SelectNavi == i+1) { pLabel->setColor(ccc3(255.0,255.0,255.0)); CCSprite * selectFrameSprite = CCSprite::create("PSubNavBackground.png"); selectFrameSprite->setScaleX(pLabel->getContentSize().width/selectFrameSprite->getContentSize().width); selectFrameSprite ->setPosition(pLabel->getPosition()); this->addChild(selectFrameSprite,zNum); } CCSprite * sprite1 = CCSprite::create(); CCSprite * sprite2 = CCSprite::create(); CCMenuItemSprite *aItem = CCMenuItemSprite::create( sprite1, sprite2, this, menu_selector(S4HeZuo::menuCallback)); CC_BREAK_IF(! aItem); aItem->setPosition(pLabel->getPosition()); aItem->setContentSize(pLabel->getContentSize()); aItem->setTag(btnTag+i+1); _menu ->addChild(aItem,zNum); } CC_BREAK_IF(! setUpSubClass2()); bRet = true; } while (0); return bRet; }
bool S411FeedBack::setUpSubClass2() { bool bRet = false; do { refreshItemImage->setOpacity(0); refreshItemImage->setEnabled(false); isMale = true; AppDelegate::S51TextViewStr = ""; feedBackSp = CCSprite::create("S41FeedBack.png"); feedBackSp->setPosition(ccp(530,330)); this->addChild(feedBackSp, zNum, 10); float pox = 487; float poy = 477; male = CCSprite::create("S49RadioSelected.png"); male->setPosition(ccp(pox,poy)); this->addChild(male,zNum); CCSprite * sprite1 = CCSprite::create(); CCSprite * sprite2 = CCSprite::create(); CCMenuItemSprite * maleItem = CCMenuItemSprite::create( sprite1, sprite2, this, menu_selector(S411FeedBack::changeSex)); maleItem->setPosition(male->getPosition()); maleItem->setContentSize(CCSizeMake(male->getContentSize().width*3, male->getContentSize().height*3)); _menu->addChild(maleItem,zNum); famale =CCSprite::create("S49RadioSelected.png"); famale->setPosition(ccp(pox+45,poy)); this->addChild(famale,zNum); famale->setOpacity(0); CCSprite * sprite3 = CCSprite::create(); CCSprite * sprite4 = CCSprite::create(); CCMenuItemSprite * faMaleItem = CCMenuItemSprite::create(sprite3, sprite4,this,menu_selector(S411FeedBack::changeSex)); faMaleItem->setPosition(famale->getPosition()); faMaleItem->setContentSize(CCSizeMake(famale->getContentSize().width*3, famale->getContentSize().height*3)); _menu->addChild(faMaleItem,zNum); float editFontSize = 10; float addWidth = 128.0; float addHeight = 45; const char * input = ""; CCScale9Sprite *sacel9SprG1=CCScale9Sprite::create("S49Submit.png"); sacel9SprG1->setOpacity(1); nameBox=CCEditBox::create(CCSizeMake(sacel9SprG1->getContentSize().width*2.8, sacel9SprG1->getContentSize().height), sacel9SprG1); nameBox->setFontName(s1FontName_macro); nameBox->setFontSize(editFontSize); nameBox->setFontColor(ccBLACK); nameBox->setInputMode(kEditBoxInputModeAny); nameBox->setPlaceHolder(input); nameBox->setPosition(ccp(240+addWidth,430+addHeight)); this->addChild(nameBox,zNum); nameBox->setDelegate(this); CCScale9Sprite *sacel9SprG2=CCScale9Sprite::create("S49Submit.png"); sacel9SprG2->setOpacity(1); telBox=CCEditBox::create(CCSizeMake(sacel9SprG2->getContentSize().width*2.8, sacel9SprG2->getContentSize().height), sacel9SprG2); telBox->setFontSize(editFontSize); telBox->setFontColor(ccBLACK); telBox->setPlaceHolder(input); telBox->setPosition(ccp(240+addWidth,400+addHeight)); this->addChild(telBox,zNum); telBox->setDelegate(this); CCScale9Sprite *sacel9SprG3=CCScale9Sprite::create("S49Submit.png"); sacel9SprG3->setOpacity(1); mobilePhoneBox=CCEditBox::create(CCSizeMake(sacel9SprG3->getContentSize().width*2.8, sacel9SprG3->getContentSize().height), sacel9SprG3); mobilePhoneBox->setFontSize(editFontSize); mobilePhoneBox->setFontColor(ccBLACK); mobilePhoneBox->setPlaceHolder(input); mobilePhoneBox->setPosition(ccp(240+addWidth,365+addHeight)); this->addChild(mobilePhoneBox,zNum); mobilePhoneBox->setDelegate(this); CCScale9Sprite *sacel9SprG4=CCScale9Sprite::create("S49Submit.png"); sacel9SprG4->setOpacity(1); mailBox=CCEditBox::create(CCSizeMake(sacel9SprG4->getContentSize().width*2.8, sacel9SprG4->getContentSize().height), sacel9SprG4); mailBox->setFontSize(editFontSize); mailBox->setFontColor(ccBLACK); mailBox->setPlaceHolder(input); mailBox->setPosition(ccp(240+addWidth,335+addHeight)); this->addChild(mailBox,zNum); mailBox->setDelegate(this); CCScale9Sprite *sacel9SprG5=CCScale9Sprite::create("S49Submit.png"); sacel9SprG5->setOpacity(1); msnBox=CCEditBox::create(CCSizeMake(sacel9SprG5->getContentSize().width*2.8, sacel9SprG5->getContentSize().height), sacel9SprG5); msnBox->setFontSize(editFontSize); msnBox->setFontColor(ccBLACK); msnBox->setPlaceHolder(input); msnBox->setPosition(ccp(240+addWidth,305+addHeight)); this->addChild(msnBox,zNum); msnBox->setDelegate(this); CCScale9Sprite *sacel9SprG6=CCScale9Sprite::create("S49Submit.png"); sacel9SprG6->setOpacity(1); addressBox=CCEditBox::create(CCSizeMake(sacel9SprG6->getContentSize().width*4, sacel9SprG6->getContentSize().height), sacel9SprG6); addressBox->setFontSize(editFontSize); addressBox->setFontColor(ccBLACK); addressBox->setPlaceHolder(input); addressBox->setPosition(ccp(270+addWidth,269+addHeight)); this->addChild(addressBox,zNum); addressBox->setDelegate(this); CCScale9Sprite *sacel9SprG7=CCScale9Sprite::create("S49Submit.png"); sacel9SprG7->setOpacity(1); submitBox=CCEditBox::create(CCSizeMake(sacel9SprG7->getContentSize().width*1.5, sacel9SprG7->getContentSize().height), sacel9SprG7); submitBox->setFontSize(editFontSize); submitBox->setFontColor(ccBLACK); // submitBox->setPlaceHolder("asdhjashdkjansda\nasdjgkjahdkjas");//input); submitBox->setPosition(ccp(210+addWidth,140+addHeight)); this->addChild(submitBox,zNum); submitBox->setDelegate(this); textView = CCUIKit::create(); CCRect aRect = CCRectMake(295, 480, 500, 100); textView->creatWithRect(aRect,this); addChild(textView); AppDelegate::isTextViewExist = false; CCScale9Sprite *sacel9SprG8=CCScale9Sprite::create("S49Submit.png"); sacel9SprG8->setOpacity(1); yanzhengBox=CCEditBox::create(CCSizeMake(sacel9SprG8->getContentSize().width*1.5, sacel9SprG8->getContentSize().height), sacel9SprG8); yanzhengBox->setFontSize(editFontSize); yanzhengBox->setFontColor(ccBLACK); yanzhengBox->setPlaceHolder(input); yanzhengBox->setPosition(ccp(210+addWidth,110+addHeight)); this->addChild(yanzhengBox,zNum); yanzhengBox->setDelegate(this); CCMenuItemFont *aItem = CCMenuItemFont::create("提交留言",this,menu_selector(S411FeedBack::submit)); aItem->setOpacity(1); aItem->setColor(ccBLACK); aItem->setScale(1.2); aItem->setPosition(ccp(550,165)); aItem->setContentSize(CCSizeMake(100,100)); _menu ->addChild(aItem,zNum); CCLabelTTF * titlelabel = CCLabelTTF::create("我要加盟", s1FontName_macro, 15); titlelabel->setPosition(ccp(visibleSize.width/2,visibleSize.height/2+155)); titlelabel->setColor(ccWHITE); this->addChild(titlelabel,zNum+1000); bRet = true; } while (0); return bRet; }
bool S132Detail::setUpSubClass2() { bool bRet = false; do { /* float titleFontSize = ScriptParser::getFontSizeFromPlist(plistDic,"title"); const char * titleLabelStr = ScriptParser::getStringFromPlist(plistDic,"title"); CCLabelTTF *titleLabel = CCLabelTTF::create(titleLabelStr, s1FontName_macro, titleFontSize); titleLabel->setAnchorPoint(ccp(0.0,1.0)); titleLabel->setPosition(ScriptParser::getPositionFromPlist(plistDic,"title")); titleLabel->setColor(ccBLACK); this->addChild(titleLabel,zNum); */ { CCSprite * aSprite = CCSprite::create("PBackBtn.png"); aSprite->setPosition( ScriptParser::getPositionFromPlist(plistDic,"PBackBtn")); this->addChild(aSprite,zNum); CCSprite * sprite1 = CCSprite::create(); CCSprite * sprite2 = CCSprite::create(); CCMenuItemSprite *aItem = CCMenuItemSprite::create( sprite1, sprite2, this, menu_selector(S132Detail::moreMenuCallback)); aItem->setPosition(aSprite->getPosition()); aItem->setContentSize(aSprite->getContentSize()); aItem->setTag(btnTag); _menu ->addChild(aItem,zNum); } /* CCSprite * showbigPicture = CCSprite::create("s133LeftBigImg.png"); showbigPicture->setPosition( ScriptParser::getPositionFromPlist(plistDic,"s133LeftBigImg")); this->addChild(showbigPicture,zNum); CCTextureCache::sharedTextureCache()->removeAllTextures(); float detailFontSize1 = ScriptParser::getFontSizeFromPlist(plistDic,"detailStr"); CCSize detailDimensionsSize1 = ScriptParser::getSizeFromPlist(plistDic,"detailStr1"); const char * detailLabelStr1 = ScriptParser::getStringFromPlist(plistDic,"detailStr1"); CCLabelTTF *detailLabel1 = CCLabelTTF::create(detailLabelStr1, s1FontName_macro, detailFontSize1, detailDimensionsSize1, kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter); detailLabel1->setAnchorPoint(ccp(0.0,1.0)); detailLabel1->setPosition(ScriptParser::getPositionFromPlist(plistDic,"detailStr1")); detailLabel1->setColor(ccBLACK); this->addChild(detailLabel1,zNum); float detailFontSize2 = ScriptParser::getFontSizeFromPlist(plistDic,"detailStr"); CCSize detailDimensionsSize2 = ScriptParser::getSizeFromPlist(plistDic,"detailStr2"); const char * detailLabelStr2 = ScriptParser::getStringFromPlist(plistDic,"detailStr2"); CCLabelTTF *detailLabel2 = CCLabelTTF::create(detailLabelStr2, s1FontName_macro, detailFontSize2, detailDimensionsSize2, kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter); detailLabel2->setAnchorPoint(ccp(0.0,1.0)); detailLabel2->setPosition(ScriptParser::getPositionFromPlist(plistDic,"detailStr2")); detailLabel2->setColor(ccBLACK); this->addChild(detailLabel2,zNum); */ //showbigPicture->setPosition( ScriptParser::getPositionFromPlist(plistDic,"S133TuWen")); //this->addChild(showbigPicture,zNum); m_pScrollView = CCScrollView::create(); string imageName = "S133TuWen"+PersonalApi::convertIntToString(AppDelegate::S1NewsSelected)+".png"; imageName = PersonalApi::getRealImageName(imageName.c_str(),"S321ScrollPic.png"); CCSprite * showbigPicture; if (imageName.compare("S321ScrollPic.png") != 0) { showbigPicture = CCSprite::create(imageName.c_str()); } else { showbigPicture = CCSprite::create(); } showbigPicture->setPosition(CCPointZero); m_pScrollView->addChild(showbigPicture,zNum); scrollMaxSizeX = showbigPicture->getContentSize().width; scrollMaxSizeY = showbigPicture->getContentSize().height; m_pScrollView->setPosition(ccp(30,100)); //¡¯?¡°a¡Ü¦¸??1.0¡Þ¨º¡À?¡Ìa¡±¨C¦Ì?¡ê¡§¡Â?¡°?¡ê¡ã CCSize showSize = CCSizeMake(showbigPicture->getContentSize().width, 450); m_pScrollView->setContentOffset(ccp(0,-(showbigPicture->getContentSize().height-showSize.height))); m_pScrollView->setViewSize(CCSizeMake(scrollMaxSizeX, showSize.height)); m_pScrollView->setContentSize(CCSizeMake(scrollMaxSizeX, scrollMaxSizeY)); m_pScrollView->setDirection(kCCScrollViewDirectionVertical); m_pScrollView->setDelegate(this); this->addChild(m_pScrollView); { CCSprite * aSprite = CCSprite::create("PPreBtn.png"); aSprite->setPosition( ScriptParser::getPositionFromPlist(plistDic,"PPreBtn")); this->addChild(aSprite,zNum); CCSprite * sprite1 = CCSprite::create(); CCSprite * sprite2 = CCSprite::create(); CCMenuItemSprite *aItem = CCMenuItemSprite::create( sprite1, sprite2, this, menu_selector(S132Detail::last)); aItem->setPosition(aSprite->getPosition()); aItem->setContentSize(aSprite->getContentSize()); aItem->setTag(btnTag+1); _menu ->addChild(aItem,zNum); } { CCSprite * aSprite = CCSprite::create("PNextBtn.png"); aSprite->setPosition( ScriptParser::getPositionFromPlist(plistDic,"PNextBtn")); this->addChild(aSprite,zNum); CCSprite * sprite1 = CCSprite::create(); CCSprite * sprite2 = CCSprite::create(); CCMenuItemSprite *aItem = CCMenuItemSprite::create( sprite1, sprite2, this, menu_selector(S132Detail::next)); aItem->setPosition(aSprite->getPosition()); aItem->setContentSize(aSprite->getContentSize()); aItem->setTag(btnTag+1); _menu ->addChild(aItem,zNum); } bRet = true; } while (0); return bRet; }