Browse Source

added remove()

Dave Schuyler 20 years ago
parent
commit
e204ad6cc6
1 changed files with 19 additions and 0 deletions
  1. 19 0
      direct/src/controls/ControlManager.py

+ 19 - 0
direct/src/controls/ControlManager.py

@@ -108,6 +108,25 @@ class ControlManager:
         controls.setCollisionsActive(0)
         self.controls[name] = controls
 
+    def remove(self, name):
+        """
+        name is any key that was used to refer to the
+            the controls when they were added (e.g. 
+            using the add(<controls>, <name>) call).
+        
+        Remove a control instance from the list of available control systems.
+        
+        See also: add().
+        """
+        assert self.notify.debugCall(id(self))
+        oldControls = self.controls.get(name)
+        if oldControls is not None:
+            print "Removing controls:", name
+            oldControls.disableAvatarControls()
+            oldControls.setCollisionsActive(0)
+            oldControls.delete()
+            del self.controls[name]
+
     def use(self, name, avatar):
         """
         name is a key (string) that was previously passed to add().