采用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 六 ...
随机推荐
- Scala - 隐式转换和隐式参数
隐士转换是Scala提供的一种语法糖 Implicit definitions are those that the compiler is allowed to insert into a prog ...
- 安装了ruby后怎么安装sass
在命令行中输入 ruby -v 查看版本号 先移除默认的https://rubygems.org源,命令为gem sources --remove https://rubygems.org/,按回车 ...
- 大数据量冲击下Windows网卡异常分析定位
背景 mqtt的服务端ActiveMQ在windows上,多台PC机客户端不停地向MQ发送消息. 现象 观察MQ自己的日志data/activemq.log里显示,TCP链接皆异常断开.此时尝试从服务 ...
- UVA1368
用一个二维数组装m个字符串,然后用一个数组装每个字符串的hamming距离.找到最小的hanming距离即可 #include<stdio.h> #include<string.h& ...
- 在脚本中使用sudo命令,将密码保存在脚本中,不需要手动输入密码
在脚本中使用sudo命令,将密码保存在脚本中,不需要手动输入密码. #!/bin/bash echo 'xxx密码xxx'|sudo -S service mysql start echo 'xxx密 ...
- thinkphp 命名空间
什么是命名空间?从广义上来说,命名空间是一种封装事物的方法.在很多地方都可以见到这种抽象概念.例如,在操作系统中目录用来将相关文件分组,对于目录中的文件来说,它就扮演了命名空间的角色.具体举个例子,文 ...
- .net 高效开发实用工具
Visual Studio Visual Studio Productivity Power tool: VS 专业版的效率工具. Web Essentials: 提高开发效率,能够有效的帮助开发人员 ...
- linux 查看文件大小
ls -lht
- ubuntu 14.04 修改网络配置
修改IP地址: vi /etc/network/interfaces
- SFDC中的DEBUG
SFDC的顾问初期,基本都是做一些配置的工作,权限,字段,工作流和审批流之类.那么在这些工作流或者审批流没有按照你预想的来运行而且你检查了多遍后没有找到问题所在的时候.你就需要DEBUG了. 做过开发 ...