COCOS2DX framed loading

The ScrollView (scrolling container) loading a large number of items will cause the game interface to freeze. In severe cases, the entire interface may freeze. Recently, I have encountered a problem of loading a large number of items in a rolling container. I will explain my method here, and I hope it will be helpful to everyone.
The scheme I use is summed up as follows: load items in frames.
1. Start the timer and start the refresh function every frame

local createNodeTimer = nil
< /span>function MainCtrl:startTimer()
if createNodeTimer == nil then
createNodeTimer
= cc.Director:getInstance():getScheduler():scheduleScriptFunc(ManiCtrl .update, 0, false)
end
end

2, in the refresh function body, judge whether the created item is greater than the specified number

local index = 1
local MAX_ITEM_NUMBER
= 50
function MainCtrl:update( )
if index <= MAX_ITEM_NUMBER then
self:callBack(index )
els e
cc.Director:getInstance():getScheduler():unscheduleScriptEntry(createNodeTimer)
end
index
= index + 1
end

3, generate item

function MainCtrl:callBack(var) local oneRecordItem = self:generateOneRecordItem(var) end< /span>

local createNodeTimer = nil
function MainCtrl:startTimer()
if createNodeTimer == nil then
createNodeTimer
= cc.Director:getInstance():getScheduler():scheduleScriptFunc(ManiCtrl.update, 0, false)
end
end

local index = 1
local MAX_ITEM_NUMBER
= 50
function MainCtrl:update()
if index <= MAX_ITEM_NUMBER then
self:callBack(index)
else
cc.Director:getInstance():getScheduler():unscheduleScriptEntry(createNodeTimer)
end
index
= index + 1
end

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3678 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.