I’ve got a level selection scene that uses a loop to insert buttons into a scroll group. This worked great when I didn’t have too many levels, but as the app has grown and the level count is now over 250 I’m getting a noticeable lag on some devices when I go to the level selection scene.
Here are the relevant bits of code:
local function createButton( i )
puzzleButton[i] = widget.newButton(
{
width = 530,
height = 155,
defaultFile = "gfx/btn/button.png",
overFile = "gfx/btn/buttonDown.png",
onEvent = gotoPuzzle
}
)
puzzleButton[i].x = 384
puzzleButton[i].y = 80 + ( ( i - 1 ) * 165 )
puzzleButton[i].packNumber = i
menuScrollGroup:insert( puzzleButton[i] )
end
menuScrollGroup = widget.newScrollView(
{
width = 768,
height = 955,
horizontalScrollDisabled = true,
topPadding = 10,
bottomPadding = 150,
hideBackground = true
}
)
for i = 1, #puzzlePackData.level do
createButton( i )
end
Does anybody have any suggestions for speeding up the load time on this scene?