diff options
author | Sai Vineet <saivineet89@gmail.com> | 2013-11-19 14:27:56 (GMT) |
---|---|---|
committer | Sai Vineet <saivineet89@gmail.com> | 2013-11-19 14:27:56 (GMT) |
commit | 92e9cc8bbd8900413c1349139e21ef12a411f684 (patch) | |
tree | 74fd6ab1b98ef99f4182075f3d328dff6f44857c /tools.py | |
parent | 2bba12a1f733b975e7f9a6bc48698ad101af5443 (diff) |
Add a Clear/Erase All tool
Problem: It is problematic to remove all bodies in the canvas, one by one,
to get a clear screen. A clear all tool is certainly needed.
Solution: Implement a Clear All tool, which also asks for confirmation before
destroying everything.
Fixes #1615
Diffstat (limited to 'tools.py')
-rw-r--r-- | tools.py | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -49,6 +49,14 @@ class Tool(object): # Stop/start simulation toggle = self.game.world.run_physics self.game.world.run_physics = not toggle + elif event.action == "clear_all": + if len(self.game.world.world.GetBodyList()) > 1: + # Get bodies and destroy them too + for body in self.game.world.world.GetBodyList(): + self.game.world.world.DestroyBody(body) + + # Add ground, because we destroyed it before + self.game.world.add.ground() elif event.action == "focus_in": self.game.in_focus = True elif event.action == "focus_out": |