初次使用quick 3.3版本--listview 判斷是否到達邊界 isItemInViewRect

在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.csdn.net/chjh0540237/article/details/43986223

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章