Lua: delete a table containing graphical objects

In my game, I have a playing field object (table) that contains all the other graphic (display.newRect) and non-graphic objects. Now I'm looking for a good way to restart the game, is there a way to delete only the gamefield object (table) and cause the inserted objects to be deleted, graphic and non-graphic together? Or should I delete graphic objects manually? Thank.

0
source share
3 answers

Put all your graphic objects in a display group (display.newGroup). When you delete a display group, it will delete all images, patches, etc.

You can add other attributes to the display group (i.e. use it as an object of the playing field).

, (group: removeSelf()) .

+1

(, destroy()), .

__gc, Lua 5.2.1. , .

+2

You will need to delete them yourself.

-1
source

All Articles