该类已经把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. DHCP 服务测试

    DHCP三个端口: 服务端:UDP 67 客户端:UDP 68 DHCPv6 客户端:UDP 546,这是需要特别开启的 DHCP failover 服务,用来做双机热备的. 实验一.DHCP服务器基 ...

  2. tomcat,很多时候,可以在服务server.xml中可以实现一些效果

    一.--日志 <Valve className="org.apache.catalina.valves.AccessLogValve" directory="log ...

  3. (原)torch中提示Unwritable object <userdata> at <?>.callback.self.XXX.threads.__gc__

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6549432.html 参考网址: https://github.com/torch/threads/i ...

  4. 使用maven命令安装jar包到本地仓库

    第三方jar包在开发工具中引入后编译没问题, 启动调试包括打包时会提示找不到jar包的错误.需要上传到maven仓库中,并在pom文件内引入. maven命令: 安装指定文件到本地仓库命令:mvn i ...

  5. saltstack 基础入门文档

    saltstack 和 Puppet Chef 一样可以让你同时在多台服务器上执行命令也包括安装和配置软件.Salt 有两个主要的功能:配置管理和远程执行.这里讲述了saltstack的基本使用方法. ...

  6. 【基础】centos 6.X 下修改图形界面为命令行界面(单用户救援模式)

    1. Linux开机引导的时候,按键盘上的e 就可以进入进入GRUB菜单界面. 2.在出现GRUB引导画面时(CentOS(2.6.18-274**)),按字母e键,进入GRUB编辑状态: 3.把光标 ...

  7. Soapui groovy 加载外部property文件

    proFile = "c:\\test.properties" log.info proFile props = new java.util.Properties() props. ...

  8. Redis 学习之路 (009) - Redis-cli命令最新总结

    资料来源: http://redisdoc.com/ http://redis.io/commands 连接操作相关的命令 默认直接连接  远程连接-h 192.168.1.20 -p 6379 pi ...

  9. git学习笔记(二)—— 创建版本库&&版本管理

    一.创建版本库 创建一个版本库非常简单,首先,选择一个合适的地方,创建一个空目录: mkdir gitHub_CXWcd gitHub_CXW git init Initialized empty G ...

  10. Cal Cat for Mac(猫咪控日历工具)安装

    1.软件简介    Cal Cat 是 macOS 系统上一款猫咪控日历工具,可以将系统内置的日历工具美化成猫咪风格的日历,超级可爱的猫咪可是猫咪控的最爱了,喜欢的朋友快快用上吧. 加州猫是一个桌面集 ...