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的更多相关文章
随机推荐
- DUBBO本地搭建及小案例 (转)
DUBBO的介绍部分我这里就不介绍了,大家可参考官方文档. DUBBO的注册中心安装 DUBBO的注册中心支持好几种,公司用到zookeeper注册中心,所以我这边只说明zookeeper注册中心如何 ...
- mysql--SQL编程(关于mysql中的日期) 学习笔记2
一.mysql数据库中的date1.DATETIME和DATE:DATETIME占用8个字节,日期范围为"1000-01-01 00:00:00"到"9999-12-31 ...
- 什么是分表和分区 MySql数据库分区和分表方法
1.为什么要分表和分区 日常开发中我们经常会遇到大表的情况,所谓的大表是指存储了百万级乃至千万级条记录的表.这样的表过于庞大,导致数据库在查询和插入的时候耗时太长,性能低下,如果涉及联合查询的情况,性 ...
- idea 不下载jar包
是因为用的gradle 然后没有设置gradle jvm
- MySQL 插入emoji 表情
create table doctorUserInfoMation ( id int not null auto_increment comment '系统ID', userId ) comment ...
- MySql随手记要
1. 显示当前正在执行的进程. SHOW FULL PROCESSLIST 2. 显示执行计划. EXPLAIN SQL语句. 3. 强制使用索个索引. 在表名后面接 FORCE INDEX(索引名称 ...
- Flume与Logstash比较
Flume与Logstash相比,个人的体会如下: Logstash比较偏重于字段的预处理:而Flume偏重数据的传输: Logstash有几十个插件,配置灵活:FLume则是强调用户的自定义开发(s ...
- wps 根据单元格值 设置单元格所在行 颜色(大于0 行红色 小于0 行xx色)
- 【colaboratory】在colab中安装mxnet
在学习<动手学深度学习>内容是,该内容用的是mxnet框架,在电脑本地安装过程中又容易出现错误,怎么也安装不上,所有的条件都尝试了. 汗颜,指的另谋他法. 只有在谷歌的学习平台上安装使用h ...
- golang 学习笔记 ---make/copy/append
package main import ( "fmt" ) func main() { a := [...]int{0, 1, 2, 3, 4, 5, 6, 7} s := mak ...