简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM