CCardSlip
该类已经把tableview封装好,可以把它当做一个精灵来用,这样做的好处是,当一个界面同时需要多个tableview的时候就可以很好的解决这个问题,而且模块也更清晰。
//-----------------------------------------------------------------
//@file gameui/Card/CardSlip.h
//@date 2014-01-03
//@desc 我的卡组滑动界面
//@action 我的卡组系统
//----------------------------------------------------------------- #ifndef __GAMEUI_CARD_CARDSLIP_H__
#define __GAMEUI_CARD_CARDSLIP_H__ #include <vector>
#include "include/ILayer.h"
#include "kernel/BaseDefine.h"
#include "cocos-ext.h" USING_NS_CC_EXT; class CCardSlip : public CBaseLayer, public CCTableViewDataSource, public CCTableViewDelegate
{
private:
CCTableView* m_pTableView;
CCTableViewCell* m_pClickCell;
CCSprite* m_pSelect;
int m_nSelectIndex;
CCPoint m_ccSelectPoint; private:
bool CreateCell(CCTableViewCell* pCell, UINT unIdx);
bool ReCreateCell(CCTableViewCell* pCell, UINT unIdx);
void ClickContent(UINT unIdx); public:
virtual bool Create();
virtual void OnTick() {}
virtual void onEnter();
virtual void onEnterTransitionDidFinish();
virtual void onExit(); virtual void tableCellTouched(CCTableView* table, CCTableViewCell* cell);
virtual CCSize cellSizeForTable(CCTableView *table);
virtual CCTableViewCell* tableCellAtIndex(CCTableView *table, unsigned int idx);
virtual unsigned int numberOfCellsInTableView(CCTableView *table); virtual void scrollViewDidScroll(CCScrollView* view);
virtual void scrollViewDidZoom(CCScrollView* view); }; #endif // __GAMEUI_CARD_CARDSLIP_H__
#include "CardSlip.h" #include "kernel/Common.h"
#include "kernel/GlobalMgr.h"
#include "kernel/CommonData/CommonData.h" bool CCardSlip::Create()
{
if (!CBaseLayer::Create())
return false;
setTouchEnabled(true);
} void CCardSlip::onEnter()
{
CBaseLayer::onEnter();
} void CCardSlip::onEnterTransitionDidFinish()
{
CBaseLayer::onEnterTransitionDidFinish(); m_pTableView = CCTableView::create(this, CCSizeMake(, ));
CC_ERROR(m_pTableView, "【CCardSlip::onEnterTransitionDidFinish】m_pTableView create failed") m_pTableView->setAnchorPoint(CCPointZero);
m_pTableView->setDirection(kCCScrollViewDirectionVertical);
m_pTableView->setPosition(CCPointZero);
m_pTableView->setDelegate(this);
m_pTableView->setVerticalFillOrder(kCCTableViewFillTopDown);
this->addChild(m_pTableView);
m_pTableView->reloadData();
} void CCardSlip::onExit()
{
CBaseLayer::onExit();
} bool CCardSlip::CreateCell(CCTableViewCell* pCell, UINT unIdx)
{
std::string g_ImgPath(CGlobalMgr::GetInstance()->GetResourcesEx());
std::string strPath; strPath = g_ImgPath + "29.png";
CCSprite* pImgSlot = CCSprite::create(strPath.c_str());
CC_ERROR_R(pImgSlot, "【CCardSlip::CreateCell】pImgSlot 为空")
pImgSlot->setPosition(CCPointZero);
pImgSlot->setAnchorPoint(CCPointZero);
pCell->addChild(pImgSlot);
return true;
} bool CCardSlip::ReCreateCell(CCTableViewCell* pCell, UINT unIdx)
{
std::string g_ImgPath(CGlobalMgr::GetInstance()->GetResourcesEx());
std::string strPath; strPath = g_ImgPath + "29.png";
CCSprite* pImgSlot = CCSprite::create(strPath.c_str());
CC_ERROR_R(pImgSlot, "【CCardSlip::ReCreateCell】pImgSlot 为空")
pImgSlot->setPosition(CCPointZero);
pImgSlot->setAnchorPoint(CCPointZero);
pCell->addChild(pImgSlot);
return true;
} void CCardSlip::ClickContent(UINT unIdx)
{ } void CCardSlip::tableCellTouched(CCTableView* table, CCTableViewCell* cell)
{
if(!table || !cell)
return; m_pClickCell = cell;
} CCSize CCardSlip::cellSizeForTable(CCTableView *table)
{
return CCSizeMake(, );
} CCTableViewCell* CCardSlip::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
CCTableViewCell* pCell = table->dequeueCell();
if (!pCell)
{
pCell = new CCTableViewCell();
pCell->autorelease();
this->CreateCell(pCell, idx);
}
else
{
pCell->removeAllChildren();
this->ReCreateCell(pCell, idx);
}
return pCell;
} unsigned int CCardSlip::numberOfCellsInTableView(CCTableView *table)
{
return ;
} void CCardSlip::scrollViewDidScroll(CCScrollView* view)
{ } void CCardSlip::scrollViewDidZoom(CCScrollView* view)
{ }
CCardSlip的更多相关文章
随机推荐
- Ubuntu x86-64汇编(4) 数值操作指令
整数乘法指令 Integer Multiplication 对于有符号数的乘法有特殊的规则, 因此无符号数乘法和有符号数乘法对应着不同的指令mul和imul. 乘法会产生两倍尺寸的数值结果, 即两个n ...
- Ubuntu字库安装
目录 [隐藏] 1 字体相关库的简介 1.1 LibXft 1.2 Cairo 1.3 Fontconfig 1.4 Freetype 1.5 Pango 2 基本概念 2.1 点阵字体与矢量字体 2 ...
- iOS获取ipa素材、提取ipa资源图片文件
当我们看到一款优秀的App时,我们可能对它的一些素材比较感兴趣,或者我们也想仿写一款类似app,那么怎么能获取到它的素材资源文件呢? 下面我以ofo举例: 1.打开iTunes,搜索ofo关键字,选择 ...
- libev loop_init分析
尼玛 C语言学不好真是桑心呐! 看了libev的代码有一种想死的感觉,但是还是要硬着头皮看下去,一定看完! /* initialise a loop structure, must be zero-i ...
- 【javascript】javascript中function(){},function(){}(),new function(){},new Function()
和java比起来,javascript真的是松散的无以复加,不过这也让我们在无聊之余,有精力去探讨一些复杂的应用,从而在开发之路上,获得一些新的想法. javascript中的类的构造 javascr ...
- TensorFlow实战
TensorFlow实战:Chapter-1(TensorFlow介绍) TensorFlow实战:Chapter-2(TensorFlow入门) TensorFlow实战:Chapter-3(CNN ...
- Docker 简单查看name和ip
原文地址:https://blog.csdn.net/wen_1108/article/details/78282268 查看docker name: sudo docker inspect -f=' ...
- 域名 ip地址 端口号
域名默认指定一个ip地址 当用域名访问网站的时候 网站会默认给个端口号80 或者自己指定 其他的 例如数据库 也是会给端口号 例如mysql 3306 域名:80 是访问iis 网站域名:3306 是 ...
- 关于less在DW中高亮显示问题
首先, 找到DW 安装目录. Adobe Dreamweaver CS5.5\configuration\DocumentTypes 中的,MMDocumentTypes.xml 这个文件,然后用记事 ...
- appium简明教程(8)——那些工具
那片笑声让我想起我的那些tool 在我生命每个角落静静为我开着 我曾以为我会永远守在她身旁 今天我们已经离去在人海茫茫 她们都老了吧 都更新换代了吧 幸运的是我曾陪她们开发 啦…… 想她 啦…… 她还 ...