Lua:删除包含图形对象的表 [英] Lua : delete table which contains graphic objects

查看:96
本文介绍了Lua:删除包含图形对象的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的游戏中,我有一个游戏场对象(表),其中包含所有其他图形对象(display.newRect)和非图形对象.现在,我正在寻找重新启动游戏的好方法,是否可以仅删除游戏对象(表)并导致插入的对象(图形和非图形对象)一起删除?还是应该手动删除图形对象? 谢谢.

In my game I've a gamefield object (table) which contains all other graphic (display.newRect) and non graphic objects. Now I'm looking for good way to restart game, is there way to remove only gamefield object (table) and cause that inserted objects will be removed, graphic and non graphic together? Or I should remove graphic objects manually? Thank you.

推荐答案

将所有图形对象放入显示组(display.newGroup). 删除显示组时,它将删除所有图像,矩形等.

Put all your graphical objects in a display group (display.newGroup). When you remove the display group, it will remove all the images, rects, etc.

您可以将其他属性添加到显示组(即,将其用作游戏场对象).

You can add other attributes to the display group (i.e. use it as your gamefield object).

如果采用这种方式,只需删除组(group:removeSelf())并创建一个新的组即可.

If you do it this way, you just need to remove the group (group:removeSelf()) and create a new one.

这篇关于Lua:删除包含图形对象的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆