If I create a module with the syntax
object.lua:
local object = display.newGroup()
view:insert(object)
return object
main.lua:
require("storyboard")
require("object")
require("some other object")
I am on a scene, and I want to remove all display objects, and reintroduce new assets.
What is the best way of doing this?
I can purgeScene to remove all display objects, and then gotoScene again to start the createScene again. I set this up quickly as it was easy, but it doesn’t feel like the right solution.
Another way that seems more like the right way is to create object.removeSelf() that listens to a custom event and removes event listeners & display objects from the display group. This sounds like the “best” way but I am wondering if there is an easier way to go about this. It seems purgeScene removes all display objects and seems like an easy way to do it, I don’t think it removes event listeners though and I am not sure how efficient this is purging and recreating the scene over and over.
[import]uid: 160288 topic_id: 33624 reply_id: 333624[/import]