[英]Delete every entity that was spawned | Python ursina
How do I delete every Entity that was spawned?如何删除生成的每个实体?
For example:例如:
Entity1 = Entity(...)
Entity2 = Entity(...)
Entity3 = Entity(...)
destroy(scene.entities) # Just an example
How do I delete all those with one or multiple lines of code without appending to a list?如何在不附加到列表的情况下删除所有具有一行或多行代码的代码?
Trying to delete every entity that was intialized试图删除每个已初始化的实体
Use利用
scene.clear()
or或者
[destroy(e) for e in scene.entities]
Using a list comprehension can be easier than using a for loop, since it won't mess up the list while you're iterating.使用列表理解比使用 for 循环更容易,因为它不会在您迭代时弄乱列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.