本文整理汇总了C++中CCTableView::setDelegate方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTableView::setDelegate方法的具体用法?C++ CCTableView::setDelegate怎么用?C++ CCTableView::setDelegate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTableView
的用法示例。
在下文中一共展示了CCTableView::setDelegate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// on "init" you need to initialize your instance
bool TableViewTestLayer::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCTableView* tableView = CCTableView::create(this, CCSizeMake(250, 60));
tableView->setDirection(kCCScrollViewDirectionHorizontal);
tableView->setPosition(ccp(20,winSize.height/2-30));
tableView->setDelegate(this);
this->addChild(tableView);
tableView->reloadData();
tableView = CCTableView::create(this, CCSizeMake(60, 280));
tableView->setDirection(kCCScrollViewDirectionVertical);
tableView->setPosition(ccp(winSize.width-150,winSize.height/2-120));
tableView->setDelegate(this);
tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
this->addChild(tableView);
tableView->reloadData();
// Back Menu
CCMenuItemFont *itemBack = CCMenuItemFont::create("Back", this, menu_selector(TableViewTestLayer::toExtensionsMainLayer));
itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
CCMenu *menuBack = CCMenu::create(itemBack, NULL);
menuBack->setPosition(CCPointZero);
addChild(menuBack);
return true;
}
示例2: init
bool ItemListScene::init()
{
bool result = GradientLayer::init();
if (result) {
setTitle(MessageItemBookTitle);
_items = GameEngine::sharedEngine()->getItems();
CCSize windowSize = CCDirector::sharedDirector()->getWinSize();
CCTableView *tableView = CCTableView::create(this, CCSize(windowSize.width, windowSize.height - TitleBarHeight));
tableView->setDirection(kCCScrollViewDirectionVertical);
tableView->setDelegate(this);
tableView->setBounceable(false);
tableView->reloadData();
this->addChild(tableView);
_scrollViewIndicator = CCDrawNode::create();
_scrollViewIndicator->drawSegment(ccp(windowSize.width - kScrollViewIndicatorMarginRight, windowSize.height),
ccp(windowSize.width - kScrollViewIndicatorMarginRight, windowSize.height - kScrollViewIndicatorHeight),
kScrollViewIndicatorRadius, ccc4f(1.0, 1.0, 1.0, 0.3));
_scrollViewIndicator->setPosition(ccp(0, -TitleBarHeight - kScrollViewIndicatorMarginVertical));
this->addChild(_scrollViewIndicator);
setTitleBarLeftButton(MessageBackButtonTitle, GameEngine::sharedEngine(), menu_selector(GameEngine::showTitle));
}
return result;
}
示例3: init
bool GameUI_MainTitle::init()
{
gameLayer = NULL;
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCSprite* title = CCSprite::create("HelloWorld.png");
CCSize size = CCDirector::sharedDirector()->getWinSize();
title->setPosition(ccp(size.width/2,size.height/2));
this->addChild(title);
CCSprite* test = CCSprite::create("Icon.png");
test->setPosition(ccp(size.width/2,size.height/2));
this->addChild(test);
CCTableView* tableView = CCTableView::create(this, CCSizeMake(60, 280));
tableView->setDirection(kCCScrollViewDirectionVertical);
tableView->setPosition(ccp(50,winSize.height/2-120));
tableView->setDelegate(this);
tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
this->addChild(tableView);
tableView->reloadData();
CCMenuItemImage* start_Button = CCMenuItemImage::create("CloseNormal.png", "CloseSelected.png", this,menu_selector(GameUI_MainTitle::ButtonDelegate_Start));
CCMenuItemImage* post_Button = CCMenuItemImage::create("CloseNormal.png", "CloseSelected.png", this,menu_selector(GameUI_MainTitle::ButtonDelegate_Post));
post_Button->setPosition(ccp(0,100));
CCMenu* menu = CCMenu::create(start_Button, post_Button, NULL);
menu->setPosition(ccp(winSize.width * 0.8f, winSize.height * 0.2f));
this->addChild(menu);
return true;
}
示例4: endNode
void CCTableViewCreator::endNode(CCNode* pNode)
{
CCTableView* pTableView = (CCTableView*)pNode;
pTableView->initWithViewSize(ccXmlAttrParse::toSize(mAttrMap["view_size"].c_str()), NULL);
pTableView->setDataSource(dynamic_cast<CCTableViewDataSource*>(mRootDelegate));
pTableView->setDelegate(dynamic_cast<CCTableViewDelegate*>(mRootDelegate));
CCNodeCreator::setAttribute(pNode);
}
示例5: CCDictionary
static int tolua_Cocos2dx_CCTableView_registerScriptHandler(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"CCTableView",0,&tolua_err) ||
!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err) ||
!tolua_isnumber(tolua_S, 3, 0, &tolua_err) ||
!tolua_isnoobj(tolua_S,4,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
CCTableView* self = (CCTableView*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'registerScriptHandler'", NULL);
#endif
if (NULL == self->getDelegate())
{
LUA_TableViewDelegate* delegate = new LUA_TableViewDelegate();
if (NULL == delegate)
return 0;
CCDictionary* userDict = static_cast<CCDictionary*>(self->getUserObject());
if (NULL == userDict)
{
userDict = new CCDictionary();
if (NULL == userDict)
return 0;
self->setUserObject(userDict);
userDict->release();
}
userDict->setObject(delegate, KEY_TABLEVIEW_DELEGATE);
self->setDelegate(delegate);
delegate->release();
}
LUA_FUNCTION nFunID = ( toluafix_ref_function(tolua_S,2,0));
int scriptHandlerType = ((int) tolua_tonumber(tolua_S,3,0));
self->registerScriptHandler(nFunID,scriptHandlerType);
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'registerScriptHandler'.",&tolua_err);
return 0;
#endif
}
示例6: init
KDbool TestList::init ( KDvoid )
{
if ( !CCLayer::initWithVisibleViewport ( ) )
{
return KD_FALSE;
}
const CCSize& tLyrSize = this->getContentSize ( );
CCLayerGradient* pBG = CCLayerGradient::create ( ccc4 ( 52, 84, 236, 200 ), ccc4 ( 149, 0, 202, 200 ) );
pBG->setContentSize ( tLyrSize );
this->addChild ( pBG, -10 );
CCSprite* pBottomLeft = CCSprite::create ( "ccb/jungle-left.png" );
this->addChild ( pBottomLeft, 10 );
pBottomLeft->setScale ( 1.5f );
pBottomLeft->setOpacity ( 210 );
pBottomLeft->setPositionWithParent ( kCCAlignmentBottomLeft );
CCSprite* pBottomRight = CCSprite::create ( "ccb/jungle-right.png" );
this->addChild ( pBottomRight, 10 );
pBottomRight->setScale ( 1.5f );
pBottomRight->setOpacity ( 210 );
pBottomRight->setPositionWithParent ( kCCAlignmentBottomRight );
CCMenuItemImage* pQuit = CCMenuItemImage::create
(
"xm_supports/CloseNormal.png", "xm_supports/CloseSelected.png", this, menu_selector ( TestList::onQuit )
);
pQuit->setScale ( 1.2f );
pQuit->setPosition ( this, kCCAlignmentTopRight, ccp ( 10, 10 ) );
this->addChild ( CCMenu::createWithItem ( pQuit ), 10 );
CCTableView* pTableView = CCTableView::create ( this, ccs ( tLyrSize.cx, tLyrSize.cy - 20.f ) );
this->addChild ( pTableView );
pTableView->setDelegate ( this );
pTableView->setDataSource ( this );
pTableView->setPosition ( ccp ( 0, 10 ) );
if ( s_tPrevPosition.x != -1 )
{
pTableView->setContentOffset ( s_tPrevPosition );
}
CCMenuItemFont::setFontSize ( 30 );
CCMenuItemFont::setFontName ( "fonts/ThonburiBold.ttf" );
return KD_TRUE;
}
示例7: init
bool RPGMapItemsMenuLayer::init(cocos2d::CCDictionary *stringList, CppSQLite3DB *db, float width, float height)
{
if(CCLayerColor::initWithColor(ccc4(0, 0, 0, 200), width, height))
{
this->m_stringList = stringList;
this->m_stringList->retain();
this->m_db = db;
this->m_itemsList = new CCArray();
this->m_itemsList->init();
CCTMXTiledMap *mainBg = CCTMXTiledMap::create(CCString::createWithFormat("map_menu3_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
mainBg->setPosition(CCPointZero);
mainBg->setTag(kRPGMapItemsMenuLayerTagBg);
this->addChild(mainBg);
CCMenu *mainMenu = CCMenu::create();
mainMenu->setTag(kRPGMapItemsMenuLayerTagMainMenu);
mainMenu->setAnchorPoint(CCPointZero);
mainMenu->setPosition(CCPointZero);
this->addChild(mainMenu);
CCMenuItemSprite *menuBack = (CCMenuItemSprite*)mainMenu->getChildByTag(kRPGMapItemsMenuLayerTagMainMenuBack);
if(!menuBack)
{
menuBack = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGMapItemsMenuLayer::onMenu));
menuBack->setPosition(ccp(40, 600));
menuBack->setTag(kRPGMapItemsMenuLayerTagMainMenuBack);
menuBack->setScale(0.5);
mainMenu->addChild(menuBack);
}
CCTableView *tableView = CCTableView::create(this, CCSizeMake(900, 570));
tableView->setDirection(kCCScrollViewDirectionVertical);
tableView->setPosition(ccp(80, 30));
tableView->setDelegate(this);
tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
tableView->setTag(kRPGMapItemsMenuLayerTagItemListTable);
this->addChild(tableView);
this->loadItemsData();
return true;
}
return false;
}
示例8: init
// on "init" you need to initialize your instance
bool TableViewTestLayer::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCTableView* tableView = CCTableView::create(this, winSize);
tableView->setDirection(kCCScrollViewDirectionHorizontal);
tableView->setPosition(ccp(0,winSize.height/2-50));
tableView->setDelegate(this);
this->addChild(tableView);
tableView->reloadData();
return true;
}
示例9: initBuystarNode
void IOSStoreLayer::initBuystarNode()
{
//获取要显示的所有道具的个数
if (m_iBuyStarCellCount <= 0 )
{
return;
}
//添加道具的tableview
CCTableView* tableView = (CCTableView*)m_pKaibaoxiangNode->getChildByTag(buystar_node_tableview_tag);
if (tableView)
{
tableView->removeFromParent();
}
tableView = CCTableView::create(this, CCSizeMake(230*m_iBuyStarCellCount, 380));
tableView->setViewSize(CCSizeMake(920, 380));
tableView->setDirection(kCCScrollViewDirectionHorizontal);
tableView->setPosition(ccp(35, 40));
tableView->setDelegate(this);
tableView->setTag(buystar_node_tableview_tag);
CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(tableView);
if (m_iBuyStarCellCount > 4)
{
tableView->runAction(CCSequence::create(CCDelayTime::create(0.01f), CCCallFuncN::create(this, callfuncN_selector(IOSStoreLayer::UpTableViewPrioority)), NULL));
}
m_pBuyStarNode->addChild(tableView, 2);
tableView->reloadData();
//左边箭头
CCSprite* pLeftArrows = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"sectionItem_buttom_left.png").c_str());
m_pBuyStarNode->addChild(pLeftArrows, 3, left_arrow_tag);
pLeftArrows->setPosition(ccp(pLeftArrows->getContentSize().width/2, tableView->getViewSize().height/2 + tableView->getPositionY()));
float dt = 1.2f;
pLeftArrows->runAction(CCRepeatForever::create(CCSequence::create(CCFadeIn::create(dt), CCFadeOut::create(dt), NULL)));
pLeftArrows->setVisible(false);
//右边箭头
CCSprite* pRightArrows = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_seasonlayerPath+"sectionItem_buttom_right.png").c_str());
m_pBuyStarNode->addChild(pRightArrows, 3, right_arrow_tag);
pRightArrows->setPosition(ccp(tableView->getViewSize().width + tableView->getPositionX(), pLeftArrows->getPositionY()));
pRightArrows->runAction(CCRepeatForever::create(CCSequence::create(CCFadeIn::create(dt), CCFadeOut::create(dt), NULL)));
}
示例10: init
bool DebugTestScene::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
// タイトル名表示
CCLabelTTF* pTitleLabel = NULL;
{
pTitleLabel = CCLabelTTF::create("DebugScene", "Arial", MultiResolution::shared()->getFontSize(24));
pTitleLabel->setPosition(ccp(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - pTitleLabel->getContentSize().height));
addChild(pTitleLabel, 1);
}
// テーブルビュー作成
{
CCTableView* pTableView =
CCTableView::create(this, CCSizeMake(visibleSize.width, visibleSize.height));
pTableView->setDirection(kCCScrollViewDirectionVertical);
pTableView->setVerticalFillOrder(kCCTableViewFillTopDown);
pTableView->setPosition(ccp(origin.x, origin.y - pTitleLabel->getContentSize().height * 2));
pTableView->setDelegate(this);
addChild(pTableView, 2);
// テーブルビューのデータを読み込み
pTableView->reloadData();
}
return true;
}
示例11: initRoomTable
bool CCLobbyView::initRoomTable()
{
const CCPoint center = this->getCenter();
CCLOG("CCLobbyView::initRoomTable:1");
this->removeRoomTable();
this->_lobbyViewDataSource = new CCLobbyViewDataSource(this);
CCLOG("CCLobbyView::initRoomTable:2");
if (this->_lobbyViewDataSource) {
// this->_lobbyViewDataSource->autorelease();
// CC_SAFE_RETAIN(this->_lobbyViewDataSource);
CCSize tableSize = this->_lobbyViewDataSource->cellSizeForTable( NULL );
tableSize.height *= 10.0f;
CCLOG("CCLobbyView::initRoomTable:3 tableSize.height[%f]", tableSize.height);
CCTableView* table = CCTableView::create( this->_lobbyViewDataSource, tableSize );
CCLOG("CCLobbyView::initRoomTable:4");
if( table )
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
float posy = this->getEditName()->getContentSize().height;
posy += this->getConsole()->getContentSize().height;
table->setContentOffset( CCPointZero );
table->setDirection(kCCScrollViewDirectionVertical);
table->setPosition( ccp( center.x - ( tableSize.width * 0.5f ), winSize.height - posy - tableSize.height - FONT_SIZE(24) ) );
table->setDelegate( this );
table->setVerticalFillOrder(kCCTableViewFillTopDown);
table->setTouchEnabled( true );
this->addChild( table, 0, Child::CCTableView_roomTable );
table->reloadData();
this->setMinRoomsInView( 10 );
return true;
} else {
CCLOG("CCLobbyView::initRoomTable:5 table create failed");
}
}
return false;
}
示例12: init
bool HelloWorld::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
m_pRecipes = CCArray::createWithContentsOfFile("recipes.plist");
m_pRecipes->retain();
CCTableView* tableView = CCTableView::create(this, visibleSize);
tableView->setDirection(kCCScrollViewDirectionVertical);
tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
tableView->setPosition(origin);
tableView->setDelegate(this);
this->addChild(tableView);
tableView->reloadData();
return true;
}
示例13: onMenu
void RPGBattleMenu::onMenu(cocos2d::CCObject *pObject)
{
CCMenuItem *menuItem = (CCMenuItem*)pObject;
SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
switch (menuItem->getTag())
{
case kRPGBattleMenuTagSkill:
{
CCLog("技能");
this->hideMenu();
this->m_selectedMenuTag = kRPGBattleMenuTagSkill;
CCMenuItemSprite *menuCancel = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGBattleMenu::onMenu));
menuCancel->setPosition(ccp(43, 596));
menuCancel->setTag(kRPGBattleMenuTagCancel);
menuCancel->setScale(0.75);
this->addChild(menuCancel);
CCTMXTiledMap *selectLayer = CCTMXTiledMap::create(CCString::createWithFormat("battle_select_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
selectLayer->setPosition(ccp((CCDirector::sharedDirector()->getWinSize().width - selectLayer->getContentSize().width) / 2, (CCDirector::sharedDirector()->getWinSize().height - selectLayer->getContentSize().height) / 2));
selectLayer->setTag(kRPGBattleSceneLayerTagSkillSelectDialog);
((RPGBattleSceneLayer*)this->m_parentNode)->addChild(selectLayer);
((RPGBattleSceneLayer*)this->m_parentNode)->enabledTouched(true);
//显示title和分隔线
addLab(selectLayer, 199, (CCString*)this->m_stringList->objectForKey("skill_title"), 25, ccp(310, 285));
CCLabelTTF *titleLab = (CCLabelTTF*)selectLayer->getChildByTag(199);
titleLab->setFontFillColor(ccc3(144, 144, 144));
CCSprite *separate = CCSprite::createWithSpriteFrameName("separate.png");
separate->setPosition(ccp(selectLayer->getContentSize().width / 2, 260));
separate->setScaleX(0.65);
separate->setTag(198);
selectLayer->addChild(separate);
//加载技能数据
CCTableView *tableView = (CCTableView*)selectLayer->getChildByTag(197);
if(!tableView)
{
tableView = CCTableView::create(this, ccp(selectLayer->getContentSize().width, selectLayer->getContentSize().height - 80));
tableView->setDirection(kCCScrollViewDirectionVertical);
tableView->setPosition(CCSizeZero);
tableView->setDelegate(this);
tableView->setVerticalFillOrder(kCCTableViewFillTopDown);
tableView->setTag(197);
selectLayer->addChild(tableView);
}
this->m_tableItems->removeAllObjects();
string wq = "";
JsonBox::Value json;
json.loadFromString(this->m_playerData->m_skill.c_str());
JsonBox::Array jsonArr = json.getArray();
for (int i = 0; i < jsonArr.size(); i++)
{
char* str = (char*)malloc(10 * sizeof(char));
OzgCCUtility::itoa(jsonArr[i].getInt(), str);
wq.append(str);
if(i + 1 < jsonArr.size())
wq.append(", ");
free(str);
}
if((int)wq.length() > 0)
{
CppSQLite3Query query = this->m_db->execQuery(CCString::createWithFormat(SKILL_QUERY, wq.c_str())->getCString());
while(!query.eof())
{
RPGSkillBtnData *skill = RPGSkillBtnData::create();
skill->m_dataId = query.getIntField("id");
skill->m_name = query.getStringField("name_cns");
skill->m_MP = query.getIntField("mp");
skill->m_skillAttack = query.getIntField("skill_attack");
skill->m_type = query.getIntField("type");
skill->m_attr = query.getIntField("attr");
skill->m_enabled = true;
//不能使用技能的情况
if(this->m_playerData->m_MP <= 0 || this->m_playerData->m_HP <= 0)
skill->m_enabled = false;
else if(this->m_playerData->m_MP < skill->m_MP)
skill->m_enabled = false;
this->m_tableItems->addObject(skill);
query.nextRow();
}
query.finalize();
}
tableView->reloadData();
//加载技能数据 end
//.........这里部分代码省略.........
示例14: setDimensions
// 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
//.........这里部分代码省略.........
示例15: init
bool UIStrengthen::init()
{
if (!CCLayer::init())
{
return false;
}
uiLayer = UILayer::create();
UILayout* strengthenRoot = dynamic_cast<UILayout*>(GUIReader::shareReader()->widgetFromJsonFile("ui/UIStrengthen.ExportJson"));
uiLayer->addWidget(strengthenRoot);
UIButton* closeButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName("CloseButton"));
closeButton->addTouchEventListener(this, toucheventselector(UIStrengthen::closeButtonClicked));
UIButton* strengthenButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName("StrengthenButton"));
strengthenButton->addTouchEventListener(this, toucheventselector(UIStrengthen::strengthenButtonClicked));
UIButton* pageLeftButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName("PageLeftButton"));
pageLeftButton->addTouchEventListener(this, toucheventselector(UIStrengthen::pageLeftButtonClicked));
UIButton* pageRightButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName("PageRightButton"));
pageRightButton->addTouchEventListener(this, toucheventselector(UIStrengthen::pageRightButtonClicked));
for (int i = 0; i < 4; i++)
{
const char* s = CCString::createWithFormat("EquipmentButton_%d", i+1)->getCString();
UIButton* equipmentButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName(s));
equipmentButton->addTouchEventListener(this, toucheventselector(UIStrengthen::equipmentButtonClicked));
}
for (int i = 0; i < 2; i++)
{
const char* s = CCString::createWithFormat("GemButton_%d", i+1)->getCString();
UIButton* gemButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName(s));
gemButton->addTouchEventListener(this, toucheventselector(UIStrengthen::gemButtonClicked));
}
for (int i = 0; i < 4; i++)
{
const char* s = CCString::createWithFormat("EquipmentImageView_%d", i+1)->getCString();
equipmentImageView[i] = dynamic_cast<UIImageView*>(uiLayer->getWidgetByName(s));
}
for (int i = 0; i < 3; i++)
{
const char* s = CCString::createWithFormat("GemImageView_%d", i+1)->getCString();
gemImageView[i] = dynamic_cast<UIImageView*>(uiLayer->getWidgetByName(s));
}
for (int i = 0; i < 2; i++)
{
const char* s = CCString::createWithFormat("GemFrontImageView_%d", i+1)->getCString();
gemFrontImageView[i] = dynamic_cast<UIImageView*>(uiLayer->getWidgetByName(s));
}
strengthenfeatureImageView = dynamic_cast<UIImageView*>(uiLayer->getWidgetByName("FeatureImageView"));
strengthenTestButton = dynamic_cast<UIButton*>(uiLayer->getWidgetByName("StrengthenTestButton"));
selectFrameImageView = dynamic_cast<UIImageView*>(uiLayer->getWidgetByName("SelectFrameImageView"));
UIPanel* tableViewPanel = dynamic_cast<UIPanel*>(uiLayer->getWidgetByName("TableViewPanel"));
CCTableView* strengthenTableView = CCTableView::create(this, CCSizeMake(strengthenTestButton->getContentSize().width, tableViewPanel->getContentSize().height));
strengthenTableView->setDirection(kCCScrollViewDirectionVertical);
strengthenTableView->setVerticalFillOrder(kCCTableViewFillTopDown);
CCPoint strengthenTestPosition = strengthenTestButton->getPosition();
strengthenTableView->setPosition(ccp(strengthenTestPosition.x, strengthenTestPosition.y - tableViewPanel->getContentSize().height));
strengthenTableView->setDelegate(this);
strengthenTableView->reloadData();
addChild(uiLayer);
addChild(strengthenTableView);
setVisible(false);
refresh();
return true;
}