该类已经把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的更多相关文章

随机推荐

  1. java中使用相对路径读取文件的写法总结 ,以及getResourceAsStream() (转)

    https://blog.csdn.net/my__sun_/article/details/74450241 读取文件的写法,相对路径 在当前的目录结构中读取test.txt的有四种写法 简单粗暴的 ...

  2. ArcGIS进行自定义投影转换(重投影)

    这里记录一下使用自定义七参数进行投影转换的过程. 1.主动创建自定义地理(坐标)变换 首先在系统工具箱里面选择创建自定义地理(坐标)变换 在弹出的窗口中输入相关参数即可. 转换方法选择COORDINA ...

  3. Windows TCP/IP 临时、保留和封锁端口行为

    由网络专家发布 转自:http://blog.163.com/abslh123@126/blog/static/792137962008628105919348/ 本文介绍 Windows 套接字应用 ...

  4. SElinux测试及排错

    一.修改SElinux的状态 #sestatus --查看状态 #setenforce --临时修改 #setenforce #getenforce #vim /etc/selinux/config ...

  5. Linux软硬连接

     曾经对软硬连接一直搞不明白,关键是怕操作错误. 硬链接不能跨区实现连接,硬链接是对原始文件的镜像,同一个inode,软连接是快捷方式,inode保存的是快捷方式的.原始文件删除,导致软连接文件无效. ...

  6. 基于Echarts的中国地图数据展示

    发布时间:2018-10-31   技术:javascript+html5+canvas   概述 基于echarts的大数据中国地图展示,结合API定制,开发样式,监听鼠标事件,实现带参数路由跳转等 ...

  7. 最常用的Java库一览(13年的文章)

    来源于:http://www.importnew.com/7530.html 本文由 ImportNew - 邢 敏 翻译自 programcreek.欢迎加入翻译小组.转载请见文末要求. 写在前面: ...

  8. 利用jquery修改href的部分字符

    试了好久 就一句代码即可. $(document).ready(function(){ $('a').each(function(){ this.href = this.href.replace('y ...

  9. BigDecimal去除末尾多余的0

    Java有自带的 stripTrailingZeros() 方法用于去除末尾多余的0 BigDecimal num = new BigDecimal("100.000"); Big ...

  10. keras callback中的stop_training

    keras这个框架简洁优美,设计上堪称典范.而tensorflow就显得臃肿庞杂,混乱不清.当然,keras的周边部件比如callbacks.datasets.preprocessing有许多过度设计 ...