简体   繁体   中英

How to remove a python turtle

I am making a game in python turtle. I have a function which spawns an extra turtle but I also want it to disappear after some time, but I can find a way to fully delete it. i have tried blanking the variable and using del but it doesn't work.

Python turtles are global entities that are never reclaimed while the turtle screen is active. To disable a turtle, simply use hideturtle() . My recommendation, if you're creating turtles dynamically, is to add disabled (hidden) turtles to a list of turtles to reuse when you need one -- you can reset() a turtle. Only create a new turtle if that list is empty.

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