I got the advice from Rob some months back that it was OK to do a full delete and recreate when one needs to update the scene. “Deleting and creating happens so quickly that it doesn’t matter how you do it”, I think was the message.
This is what I do (for non-performance critical menu system scenes):
[Lua]
function reloadScene(event)
local name = storyboard.getCurrentSceneName()
local scene = storyboard.getScene(name)
local group = scene.view
for i=group.numChildren, 1, -1 do
display.remove(group[i]) group[i] = nil
end
scene:createScene(event)
end
[/Lua]
However, after Widget 2.0 appeared, I have noticed that the GUI actually “blinks” briefly sometimes while deleting and re-creating. The deleting/re-creating presumably now takes so long that the GUI thread renders the deleted scene before it is re-created. This makes the GUI look buggy.
-
Is Widget 2.0 slower than Widget 1.0?
-
Is it no more advisable to do a full delete and re-create?
-
Do I now have to write custom code for every object I want to disable or enable after the scene is created? (I pray that this is not the case)
Please let me know how I can solve this in a simple way that does not involve lots of new code.
Thanks!