本文整理汇总了C++中CCTableView::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTableView::setPosition方法的具体用法?C++ CCTableView::setPosition怎么用?C++ CCTableView::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTableView
的用法示例。
在下文中一共展示了CCTableView::setPosition方法的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 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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)));
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: 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
//.........这里部分代码省略.........
示例11: 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;
}
示例12: menuItemClicked_TanSuo
void TanSuoLayer::menuItemClicked_TanSuo(CCObject *pSender)
{
int tag = ((CCMenuItem*)pSender)->getTag();
if (tag == Tag_MenuItem_YiJianTanSuo)
{
if (m_bIsJieFeng)
{
string infoStr = LFStrings::getValue("XuYaoJieFeng");
UnblockWarnDialog* pDlg = UnblockWarnDialog::create(infoStr);
CCDirector::sharedDirector()->getRunningScene()->addChild(pDlg, 300);
return;
}
if (MyselfManager::getManager()->getMyZhuJueData()->getVipLevel() < 3)
{
FXToast *layer = FXToast::create(LFStrings::getValue("XunBao_VipNeed"));
CCDirector::sharedDirector()->getRunningScene()->addChild(layer);
return;
}
m_bDiscoverAll = true;
addObserver(callfuncO_selector(TanSuoLayer::rsp_tansuo), MSG_discoverRsp);
mCmdHlp->cmdDiscover(m_bDiscoverAll);
}
else if (tag == Tag_MenuItem_TanSuo)
{
m_bDiscoverAll = false;
addObserver(callfuncO_selector(TanSuoLayer::rsp_tansuo), MSG_discoverRsp);
mCmdHlp->cmdDiscover(m_bDiscoverAll);
}
else if (tag == Tag_MenuItem_JieFen)
{
if (mDestroyCount >= m_nMaxCountDestroy)
{
m_bIsJieFeng = true;
m_nSelectProId = -1;
if (! EquipmentManager::getManager()->isSpareEnoughToSaveEquip(1))
{
EquipBagNotEnoughDialog *layer = new EquipBagNotEnoughDialog;
layer->showGoToFenJieDialog();
}
CCSize visSize = CCDirector::sharedDirector()->getWinSize();
BaseSprite* dialog = BaseSprite::create("juqing_duihuakuang.png");
dialog->setPosition(ccp(visSize.width/2, visSize.height/2));
//label 提示
{
/*CCLabelTTF* label = CCLabelTTF::create(LFStrings::getValue("XunBao_XuanZeHeroTiShi").c_str(),
fontStr_kaiti, m_nFontSize, CCSize(425, 0), kCCTextAlignmentLeft);
label->setAnchorPoint(ccp(0.5, 1));
label->setPosition(ccp(dialog->getContentSize().width/2, 250));
dialog->addChild(label, 1);*/
CCLabelTTF *title = CCLabelTTF::create(LFStrings::getValue("JieChuFengYin").c_str(),fontStr_kaiti,m_nFontSize);
title->setAnchorPoint(ccp(0.5,1));
title->setPosition(ccp(dialog->getContentSize().width/2, 250));
dialog->addChild(title, 1);
CCLabelTTF *chuanqi = CCLabelTTF::create(LFStrings::getValue("ChuanQiZhuangBei").c_str(),fontStr_kaiti,m_nFontSize);
chuanqi->setAnchorPoint(ccp(0.5,1));
chuanqi->setPosition(ccp(title->getPositionX() - title->getContentSize().width / 2 + m_nFontSize * 7 + chuanqi->getContentSize().width / 2, 250));
dialog->addChild(chuanqi, 1);
chuanqi->setColor(ccc3(235,106,12));
}
{
m_lMenuItemList.clear();
//mHeros = MyselfManager::getManager()->getTeamActors_ZhenShen(Actor_All, LF_UnLock);
mHeros = MyselfManager::getManager()->getTeamActors_ZhenShen(Actor_ShangZheng, LF_UnLock);
//tabel view
CCTableView *tabelView = CCTableView::create(this, CCSizeMake(560, 158));
tabelView->setDirection(kCCScrollViewDirectionHorizontal);
tabelView->setPosition(ccp(41, 44));
tabelView->setDelegate(this);
dialog->addChild(tabelView);
tabelView->reloadData();
}
//确认 取消按键
CCMenu* menu = CCMenu::create();
menu->setPosition(CCPointZero);
menu->setTag(0);
//
{
LFAlert* lfAlert = new LFAlert();
lfAlert->setTag(TAG_AwardDisplayer_Layer);
lfAlert->setBaseContainer(dialog,menu);
lfAlert->setZoneCanotTouch();
CCDirector::sharedDirector()->getRunningScene()->addChild(lfAlert,128, TAG_AwardDisplayer_Layer);
lfAlert->release();
}
return;
}
else
{
MessageDisplay* layer = MessageDisplay::create("ERROR!");
CCDirector::sharedDirector()->getRunningScene()->addChild(layer);
return;
}
}
//.........这里部分代码省略.........
示例13: while
bool S2TestMain::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(! CCLayer::init());
//每个项目都要创建的东西
_menu = CCMenu::create(NULL);
_menu->setPosition(CCPointZero);
CC_BREAK_IF(! _menu);
this->addChild(_menu, 2);
//*****************背景图/ NavBar/ Title*****************//
{
CCSprite * aSprite = CCSprite::create("pBackground.png");
aSprite->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
//CC_BREAK_IF(! aSprite);
this->addChild(aSprite,1);
aSprite ->getTexture()->setAntiAliasTexParameters();//抗锯齿
}
{
CCSprite * aSprite = CCSprite::create("pNavBar.png");
aSprite->setPosition(s2Position2_macro(aSprite));
//CC_BREAK_IF(! aSprite);
this->addChild(aSprite,1);
}
{
CCLabelTTF * titleLabel = CCLabelTTF::create("Test 1", "Arial", s2FontSize1_macro);
titleLabel->setPosition(s2Position1_macro(aItem));
//CC_BREAK_IF(! aSprite);
this->addChild(titleLabel,1);
}
//*****************BackButton And BackLabel*****************//
{
CCSprite * sprite1 = CCSprite::create("pBackButton.png");
CCSprite * sprite2 = CCSprite::create("pBackButton.png");
CCMenuItemSprite *aItem = CCMenuItemSprite::create(
sprite1,
sprite2,
this,
menu_selector(S2TestMain::menuOnBackCallback));
CC_BREAK_IF(! aItem);
aItem->setPosition(s2Position3_macro(aItem));
_menu ->addChild(aItem,1);
{
CCLabelTTF *label_back = CCLabelTTF::create("Test", "Arial", s2FontSize2_macro, sprite1->getContentSize(), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
label_back->setPosition(s2Position3_macro(aItem));
this ->addChild(label_back,2);
}
}
//*****************pRecButton*****************//
{
CCSprite * sprite1 = CCSprite::create("pRecButton.png");
CCSprite * sprite2 = CCSprite::create("pRecButton.png");
CCMenuItemSprite *aItem = CCMenuItemSprite::create(
sprite1,
sprite2,
this,
menu_selector(S2TestMain::menuShowPracticeList));
CC_BREAK_IF(! aItem);
aItem->setPosition(s2Position4_macro(aItem));
_menu ->addChild(aItem,1);
}
//*****************Practice List 集,包括小TableView和背景*****************//
{
CCSprite *spritePracticeList = CCSprite::create("s2Popover.png");
spritePracticeList->setPosition(s2Position5_macro(aSprite));
CC_BREAK_IF(! spritePracticeList);
spritePracticeList->setTag(s2Tag4);
spritePracticeList->setVisible(false);
this->addChild(spritePracticeList,10);
CCTableView* pTableView = CCTableView::create(this, s2Size1_macro(aTableView));
CC_BREAK_IF(! pTableView);
pTableView->setDirection(kCCScrollViewDirectionVertical);
pTableView->setPosition(ccp(129,160));//bug
pTableView->setDelegate(this);
pTableView->setTag(s2Tag2);
// 设置顺序是自上往下
pTableView->setVerticalFillOrder(kCCTableViewFillTopDown);
spritePracticeList->addChild(pTableView);
pTableView->reloadData();
//.........这里部分代码省略.........
示例14: initKaibaoxiangNode
void IOSStoreLayer::initKaibaoxiangNode()
{
//获取要显示的所有道具的个数
if (m_iBaoxiangCellCount <= 0 )
{
return;
}
//添加道具的tableview
CCTableView* tableView = (CCTableView*)m_pKaibaoxiangNode->getChildByTag(kaibaoxiang_node_tableview_tag);
if (tableView)
{
tableView->removeFromParent();
}
tableView = CCTableView::create(this, CCSizeMake(230*m_iBaoxiangCellCount, 380));
// tableView->ignoreAnchorPointForPosition(false);
// tableView->setAnchorPoint(ccp(0.5f, 0.5f));
tableView->setViewSize(CCSizeMake(920, 380));
tableView->setDirection(kCCScrollViewDirectionHorizontal);
tableView->setPosition(ccp(35, 40));
// tableView->setPosition(ccp(m_pBg->getContentSize().width/2, m_pBg->getContentSize().height/2));
tableView->setDelegate(this);
tableView->setTag(kaibaoxiang_node_tableview_tag);
CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(tableView);
if (m_iBaoxiangCellCount > 4)
{
tableView->runAction(CCSequence::create(CCDelayTime::create(0.01f), CCCallFuncN::create(this, callfuncN_selector(IOSStoreLayer::UpTableViewPrioority)), NULL));
}
m_pKaibaoxiangNode->addChild(tableView, 2);
tableView->reloadData();
if (m_iBaoxiangCellCount > 0 && m_iBaoxiangCellCount <= 2)
{
tableView->setViewSize(CCSizeMake(230*m_iBaoxiangCellCount, 380));
}
if(m_iBaoxiangCellCount == 1)
{
tableView->setPosition(ccp(m_pBg->getContentSize().width/2 - 115, 40));
}
else if (m_iBaoxiangCellCount == 2)
{
tableView->setPosition(ccp(m_pBg->getContentSize().width/2 - 220, 40));
}
else if (m_iBaoxiangCellCount == 3)
{
tableView->setPosition(ccp(m_pBg->getContentSize().width/2 - 345, 40));
}
//右边说明文字背景
CCSprite* pLeftBg = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"main_shangdian_daoju_bg_2.png").c_str());
pLeftBg->setPosition(ccp(tableView->getPositionX() - pLeftBg->getContentSize().width/2, tableView->getPositionY()+pLeftBg->getContentSize().height/2));
m_pKaibaoxiangNode->addChild(pLeftBg);
pLeftBg->setTag(leftbg_tag);
//右边说明文字
CCLabelTTF* pLabel = CCLabelTTF::create("", fontStr_katong, 24, CCSize(180, 0), kCCTextAlignmentLeft);
pLabel->setColor(fontColor_Store);
pLabel->setPosition(ccp(pLeftBg->getContentSize().width/2, pLeftBg->getContentSize().height/2+10));
pLeftBg->addChild(pLabel, 1);
pLabel->setTag(leftbg_string_tag);
//下边说明文字背景
CCSprite* pDownBg = CCSprite::create(ResManager::getManager()->getSharedFilePath(g_storelayerPath+"main_shangdian_daoju_bg_3.png").c_str());
pDownBg->setPosition(ccp(pLeftBg->getContentSize().width/2, pLeftBg->getContentSize().height/2));
pLeftBg->addChild(pDownBg, 1, downbg_tag);
CCLabelTTF* pDownLabel = CCLabelTTF::create("", fontStr_katong, 24, CCSize(200, 0), kCCTextAlignmentCenter);
pDownLabel->setPosition(ccp(pDownBg->getPositionX()-3, 60));
pDownBg->addChild(pDownLabel, 1);
pDownLabel->setTag(downbg_string_tag);
if (m_enumComeFrom != from_SeasonSelector)
{
pDownBg->setVisible(false);
pDownLabel->setVisible(false);
}
this->setComefrom(m_enumComeFrom);
}
示例15: 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
//.........这里部分代码省略.........