In order to tell an object which inherits from DirectObject
to stop listening to events, we can use two methods. The first method, and the simplest, is ignoreAll()
. A call to this method would look like the following:
self.ignoreAll()
This call turns off all event responses for the object. For instance, if we called this method within the World
class, the World
class would no longer respond to any of the events we have told it to listen to with self.accept
.
The second method we can use is the ignore()
method. We can provide ignore()
with an event string name just like the accept()
method to stop listening to that particular event. For example:
self.ignore("a")
That call would stop event response to the A key being pressed.
If we wanted to respond to an event only once, we could use the acceptOnce()
method instead of the accept()
method.