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的更多相关文章
随机推荐
- [转载]Windows x64下配置ffmpeg的方法
ffmpeg简介 FFmpeg 是一款跨平台的,对视频.音频进行录制.转换.播放的命令行形式软件,它使用的是 libavcodec 编解码器.FFmpeg 官方网站是 http://ffmpeg.or ...
- 【原创】kerberos无密码登录
通常在远程客户端上登录kerbros都需要密码,在学习hadoop的时候提到了ktutil这个工具,这里将使用方法贴出来. 用到的命令如下: 1.ktutil 2.add_entry -passwor ...
- codevs 1576 最长严格上升子序列
题目链接:http://codevs.cn/problem/1576/ 题目描述 Description 给一个数组a1, a2 ... an,找到最长的上升降子序列ab1<ab2< .. ...
- Linux下wc命令统计文件行数/词数/字符数/最长行字符数
wc命令帮助 $ wc --help Usage: wc [OPTION]... [FILE]... or: wc [OPTION]... --files0-from=F Print newline, ...
- 微信扫码支付springboot版本
发布时间:2018-11-06 技术:springboot+freemarker 概述 该项目是一个采用springboot构建的web项目,主要实现了微信扫码支付功能.包含最基本的创建订单, ...
- (转载)JWebUnit做Web项目自动化测试
原址:http://blog.csdn.net/plainfield/archive/2007/07/02/1675546.aspx JwebUnit加构在HttpUnit上,实际上也可以这么说是Ht ...
- 【DM】Combating Web Spam with TrustRank - 用TrustRank对抗网络垃圾邮件
[论文标题]Combating Web Spam with TrustRank (Proceedings 2004 VLDB Conference) [论文作者]Zolt´an Gy¨ongyi,He ...
- cd及目录快速切换
一.cd ~ 切换到用户目录 二.cd - cd - 返回进入当前目录前所在目录 三.pushd.popd.dirs 在Linux的多目录命令提示符中工作是一种痛苦的事情,但以下这些利用lin ...
- Web压力架构
原文地址:https://www.cnblogs.com/lori/archive/2015/03/27/4370827.html Web压力架构... 1 一 系统性能测试概述... 1 1.1 性 ...
- Mac OS下Android Studio的Java not found问题,androidfound
Android Studio正式版已经发布一段时间了,使用Mac版的Android Studio可能与遇到Java not found:Android Studio was unable to fin ...