oDustGgg个人原创、欢迎转载、转载请注明出处、http://blog.csdn.net/odustggg/article/details/8171230
一、创建列表层
function create_listview()
local layer = CCLayerColor:layerWithColorWidthHeight(ccc4(255, 0, 0, CORLORLAYERENABLE),640, 200)
layer:setAnchorPoint(CCPointMake(0,0))
layer:setIsRelativeAnchorPoint(true)
--anchorPoint这个属性虽然是属于CCNode的、但CCLayer设置anchorPoint没有效果、
--CCLayer的anchorPoint被默认设定在(0, 0)、在setAnchorPoint之前要先设置setIsRelativeAnchorPoint = true
layer:setPosition(PT(165,120))
-- 两种排列 CCListViewModeHorizontal 水平 CCListViewModeVertical 竖直
m_pList = CCListView:viewWithMode(CCListViewModeHorizontal)
-- 初始化控件
ListView m_pList:setContentSize(CCSize(640,200))
m_pList:setDelegateName('testListView') m_pList:setAnchorPoint(CCPointMake(0,0))
m_pList:setPosition(PT(0,0))
--两种分隔CCListViewCellSeparatorStyleNone CCListViewCellSeparatorStyleSingleLine
m_pList:setSeparatorStyle(CCListViewCellSeparatorStyleNone)
layer:addChild(m_pList) return layerend
二、实现的方法
--返回有多少页
function testListView_CCListView_numberOfCells(listview,data)
data.nNumberOfRows= listview:size()
end
--listview在滑动中
function testListView_triggerDidScrollToRow(nRow)
local i = nRow
cclog("scrolling:"..i)
end
--cell被选中
function testListView_triggerDidClickCellAtRow(nRow) local i = nRow
cclog("clicked:"..i)
end
--将listview层的触摸打开
function setTouch_openLayer(layer)
layer:registerScriptTouchHandler(onTouch_openLayer,nil,-129,nil)
layer:setIsTouchEnabled(true)
end
--具体显示什么内容,每一页的内容
function testListView_triggerCellForRow(listview,data)
m_nCurrnetPage = data.nRow + 1 --data.nRow从0开始
local cell = CCListViewCell:node()
cell:setOpacity(0)
cell:setContentSize(m_pList:getContentSize())
cell:setSelectionColor(ccc4(0, 0, 0, 0))
data.cell = cell
_curCell = cell
local listItemSize = CCSize:new(m_pList:getContentSize().width , m_pList:getContentSize().height)
for n = 1, data.nNumberOfRows do
cell:addChild(xxxxxx)
end
end
三、listview的使用
listview_layer = create_listview()
_layer:addChild(listview_layer,2)
setTouch_openLayer(listview_layer)
分享到:
相关推荐
cocos2d-x+lua游戏demo源码 xcode工程
++++++++++++ lua cjson c ++++++++++++ strbuf c ++++++++++++ strbuf h AppDelegate cpp 中添加 line 8 extern "C" { int luaopen cjson lua State L ; } line 46 luaopen cjson pEngine >...
使用cocos2d-x lua和code ide编写的贪吃蛇小游戏 反转贪食蛇一改传统贪食蛇的玩法,游戏大屏幕一分为二。半屏采用传统贪食蛇玩法,半屏加入反转元素,触屏即向相反方向转头! 除此之外,还新增多种规则,等着...
Cocos2d-x实战++JS卷++Cocos2d-JS开发+PDF电子书下载+带书签目录+完整
cocos2d-x 实现一个简单的小游戏,适合新手入门
使用_cocos2d-x_和_Lua_快速开发游戏.pdf
1.我这里说的iOS原生SDK是指那些完全用Objective-C语言开发,为原生iOS程序设计的SDK 2.这里假设游戏的主要逻辑使用lua实现,对于主要逻辑
4、【cocos2d-x IOS游戏开发-捕鱼达人4】基本游戏框架 资源引用页: 5、【cocos2d-x IOS游戏开发-捕鱼达人5】C++中函数代理与信号插槽机制 资源引用页: 6、【cocos2d-x IOS游戏开发-捕鱼达人6】实现开始菜单 资源...
物理编辑器 cocos2d box2d.很好用哦
9、【cocos2d-x IOS游戏开发-捕鱼达人9】鱼与动画 资源引用页: 10、【cocos2d-x IOS游戏开发-捕鱼达人10】鱼的产生和移动 资源引用页: 11、【cocos2d-x IOS游戏开发-捕鱼达人11】鱼的产生和移动:完善 资源引用页...
Cocos2d-x之LUA脚本引擎深入分析
cocos2d_x3.4 + vs13 喵星战争代码移植 《cocso2d-x 权威指南》 满硕泉 著
Cocos2d-x windows vs2010 配置图文详解
Cocos2d-x 1.0.1-x-0.11.0的代码手册
入门cocos2d-x不可多得的好资料,环境说明,工程搭配,实例教程
cocos2d-x进阶教程1_6LuaTable使用1.mp4 cocos2d-x进阶教程1_7LuaTable使用2.mp4 cocos2d-x进阶教程1_8LuaTable使用3.mp4 cocos2d-x进阶教程1_9LuaTable读写数据文件.mp4 cocos2d-x进阶教程1_10在Lua中实现串行化....
Cocos2d-x实战_Lua卷 _第2版
Cross-platform game engine cocos2d-x Introduction
cocos2d-x +luajit使用,测试工程文件,使用luajit生成文件
最新版的cocos2d-x实战 lua卷,分享给大家