初次使用quick 3.3版本--listview 判断是否到达边界 isItemInViewRect

本文详细介绍了Quick3.3框架中isItemInViewRect方法的使用及改进方式,通过调整源代码确保item和视图矩形都转换为世界坐标,从而准确判断item是否位于可视区域内。

在quick 3.3里面存在isItemInViewRect方法判断是否在可视区域,isItemInViewRect 源代码修改如下即可

function UIListView:isItemInViewRect(pos)
local item
if "number" == type(pos) then
item = self.items_[pos]
elseif "userdata" == type(pos) then
item = pos
end


if not item then
return
end

local bound = item:getBoundingBox()
local nodePoint = self.container:convertToWorldSpace(
cc.p(bound.x, bound.y))
bound.x = nodePoint.x
bound.y = nodePoint.y


local viewRectPos = self:convertToWorldSpace(cc.p(self.viewRect_.x,self.viewRect_.y))  
    local viewRect = cc.rect(viewRectPos.x,viewRectPos.y,self.viewRect_.width,self.viewRect_.height)  


return cc.rectIntersectsRect(viewRect, bound)
end

源代码只把item坐标转化成世界坐标,但是没有将viewRect_转化成世界坐标


参考自http://blog.youkuaiyun.com/chjh0540237/article/details/43986223

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值