0
votes

I have a new problem... I have a constuctor like this:

function Box.new(indexBox, item, imgClose, imgOpen) -- constructor
  local object = {
    indexBox = indexBox,
    item = item,
    imgClose = display.newImage( imgClose ),
    imgOpen = imgOpen
  }
  return setmetatable( object, Box_mt )
end

During the process I've created some Box objects and now I've finished to use them, so I want to remove this Box objects removing all the content of the object, included the image. Are there any easy way to do this?

Thanks!

1

1 Answers

1
votes

To delete all the box objects, you need some way to access all of them. The traditional and by far (IMHO) approach is to have a table storing references to the Box 'instances'. With such an approach all you would need is:

--BoxesTable contains all the boxes declared
for _,box in ipairs(BoxesTable) do
    box:removeSelf()
end