采用cocos2d-x lua 的listview 实现pageview的翻页效果之上下翻页效果
--翻页滚动效果
local function fnScrollViewScrolling( sender,eventType)
-- body
if eventType == 10 then
local bposX = sender:getPercentage()*100
_bPosX = bposX
end
if not _bPosX then
return
end
print("-------bposX=",_bPosX)
if ccui.ScrollviewEventType.scrolling == eventType or eventType == 9 then
_IsRolling = true
elseif eventType == 12 then
local edposX = sender:getPercentage()*100
local dispox = edposX - _bPosX
print("--------dispox=",dispox)
if dispox < 0 then
_currPercent = _currPercent - _addPercent
if _currPercent >= 100 then
_currPercent = 100
end
elseif dispox > 0 then
_currPercent = _currPercent + _addPercent
if _currPercent <= 0 then
_currPercent = 0
end
end
sender:scrollToPercentVertical(_currPercent,0.1,false)
print("--------_currPercent=,_addPercent=",_currPercent,_addPercent)
_IsRolling = false
end
end
--绘制商店列表数据
function shopItemList( pBg,tItem )
-- body
require "src/libs/LuaListView"
local itemList = pBg:getChildByTag(999)
if not itemList then
itemList = LuaListView:create()
itemList:setBounceEnabled(true)
itemList:setSize(cc.size(775, 318))
itemList:setPosition(387.5,159+10)--230
itemList:setAnchorPoint(cc.p(0.5,0.5))
itemList:setDirection(ccui.ScrollViewDir.vertical)
itemList:addEventListenerListView(fnScrollViewScrolling)
itemList:setTag(999)
pBg:addChild(itemList)
else
itemList:removeAllItems()
_t_item = {}
end
local point_y = 52
local num = math.ceil(#tItem/2)
local addLayNum = math.mod(num,3)--当不够整页的话根据差别的个数添加空白条目实现上下整体翻页效果
print("-----------------num=,addLayNum=",num,addLayNum)
local layoutSize = cc.size(775,106)
for i=1,num do
local dLayout = ccui.Layout:create()
dLayout:setSize(layoutSize)
if tItem[2*i-1] then
local itemInfo1 = drawShopItemInfo(tItem[2*i -1],2*i -1)
itemInfo1:setPosition(194,point_y) --67
dLayout:addChild(itemInfo1)
end
if tItem[2*i] then
local itemInfo2 = drawShopItemInfo(tItem[2*i],2*i)
itemInfo2:setPosition(582,point_y)
dLayout:addChild(itemInfo2)
end
itemList:pushBackCustomItem(dLayout)
end
if addLayNum ~= 0 then
local disNum = 3- addLayNum
for i=1,disNum do
local dLayout = ccui.Layout:create()
dLayout:setSize(layoutSize)
itemList:pushBackCustomItem(dLayout)
end
end
local height = itemList:getInnerContainer():getContentSize().height-318
print("itemList:getInnerContainer():getContentSize().height=",itemList:getInnerContainer():getContentSize().height)
_addPercent=(318/height)*(-100)
end
采用cocos2d-x lua 的listview 实现pageview的翻页效果之上下翻页效果的更多相关文章
- cocos2d-x lua 使用ListView
cocos2d-x lua 使用ListView version: cocos2d-x 3.6 本文主要讲述:使用Cocos Studio创建ListView,和列表项的模板,代码中通过模板创建列表的 ...
- 采用cocos2d-x lua 制作数字滚动效果样例
require "Cocos2d"require "Cocos2dConstants"local testscene = class("testsce ...
- lua 创建listview
只要是新的聊天对象就创建一个新的listview local name = tolua.cast(UIHelper:seekWidgetByName(self.nameItem, "name ...
- 它们的定义ListView,实现Item除去滑动和滑出菜单效果
这个程序是基于变化从网上开源项目,详情货源忘记.懒得去搜索,.假设有不合适的地方.请与我联系作者.我会及时回复和处理! 序中主要包括两个ListView,一个是实现側滑删除.一个是側滑出菜单,代码中的 ...
- Cocos Creator 获取当前 Pageview 翻页到第几页的事件索引
新建一个js,叫做 pageAction写一个方法 pageViewClick:function(event,coustom){ var node = event.node; this.pageInd ...
- linux服务器开发一 基础
注:本文仅限交流使用,请务用于商业用途,否则后果自负! Linux 1.Linux介绍 Linux是类Unix计算机操作系统的统称. Linux操作系统的内核的名字也是“Linux”. Linux这个 ...
- IOS开发-属性动画和关键帧动画的使用
CAMediaTiming是一个协议(protocol),CAAnimation是所有动画类的父类,但是它不能直接使用,应该使用它的子类. 继承关系: CoreAnmiation 核心动画 简写CA ...
- 从零开始学习PYTHON3讲义(八)列表类型跟冒泡排序
<从零开始PYTHON3>第八讲 前面我们见过了不少的小程序,也见过了不少不同类型的变量使用的方法.但目前我们涉及到的,还都是单个的变量和单个的立即数.以变量来说,目前我们见到的,基本都 ...
- Linux 文件/目录操作详解
目录 Linux 文件/目录操作详解 初识Linux 一.文件/目录显示命令 ls 二.目录创建命令 mkdir 三.目录转移命令 cd 四.当前目录显示命令 pwd 五.文件处理命令 rmdir 六 ...
随机推荐
- phylogeny analysis
Multiple Alignment: MUSCLE ProbCons T-Coffee ClustalW Alignment curation: Gblocks Remove positions w ...
- Apache报错信息之Invalid command 'Order', perhaps misspelled or defined by a module not included in the server config
今天配置开启Apache虚拟主机时, 然后日志报错提示: Invalid command 'Order', perhaps misspelled or defined by a module not ...
- sublime
sublime的格式化快捷键 其实在sublime中已经自建了格式化按钮:Edit -> Line -> Reindent 只是sublime并没有给他赋予快捷键,所以只需加上快捷 ...
- JUC学习笔记--Thread多线程基础
实现多线程的两种方法 java 实现多线程通过两种方式1.继承Thread类 ,2.实现Runnable接口 class Newthead extends Thread{ public void ru ...
- 修改pip更新源
修改pip更新源 pip安装时默认访问pypi的,但是pypi的速度对于国内来说有点慢,还在国内也有一些pip的镜像源,造福广大程序员 pipy国内镜像目前有: http://pypi.douban. ...
- js设置css样式.
在js设置css样式做法 var obj = document.getElementById('div'); obj.style.width = '100px'; obj.style.height = ...
- FZU 2105Digits Count(线段树 + 成段更新)
Description Given N integers A={A[0],A[1],...,A[N-1]}. Here we have some operations: Operation 1: AN ...
- thinkphp3.2.3中U()方法和redirect()方法区别
今天博主看3.1的教程,学着3.2,就遇到了这个坑,怎么就是不跳转呢,很纳闷!! 在thinkphp3.1 中 U()方法是可以执行跳转的(看视频教程里面是可以的,博主没有测试过). 但是在think ...
- linux 基础命令与文件管理
Linux终端介绍 Shell提示符 Bash Shell基本语法 基本命令的使用:ls.pwd.cd 查看系统和BIOS硬件时间 Linux如何获得帮助 Linux关机命令:shutdow.in ...
- MyBatis源码分析(5)——内置DataSource实现
@(MyBatis)[DataSource] MyBatis源码分析(5)--内置DataSource实现 MyBatis内置了两个DataSource的实现:UnpooledDataSource,该 ...