I’ve implemented composite objects as collections of hierarchical GOs created by collection factories. Once such parnt object is hit, I decompose it, and re-parent all child objects to another GO in the main collection.
Should Ianually release child GOs when I remove ttheir new parent?
function init(self)
--[[ set up the plumbing ]]--
self.board_id = hash("/board")
msg.post(".", "acquire_input_focus")
end
board is a GO defined in the main collection, so I assume there’s no need to create or delete it manually
Then I have this part:
local function handle_collision(self, obj_id)
local children = get_children_go(self, obj_id)
for _, child_id in ipairs(children) do
go.set_parent(child_id, self.board_id)
end
go.delete(obj_id)
end
called for a collision, so that all child objects are parented under board.
Should I delete all the child objects I set board as a parent in final() or they will be deleted as its children automatically ?