def deactivate(self): """Deactivate the CatchPowerUp from preventing the paddle from catching the ball. """ self.game.paddle.ball_collide_callbacks.remove(self._catch) receiver.unregister_handler(self._release_ball) for ball in self.game.balls: ball.release() # Release a currently caught ball.
def test_unregister_handler(self): def handler(): pass receiver._handlers['test_event'].append(handler) receiver.unregister_handler(handler) self.assertNotIn(handler, receiver._handlers['test_event'])
def test_unregister_handler(self): def handler(): pass receiver._handlers['test_event'].append(handler) receiver.unregister_handler(handler) self.assertNotIn(handler, receiver._handlers['test_event'])
def __init__(self, game): super().__init__(game) game.ball.anchor(game.paddle.rect.midtop) game.ball.visible = False game.over = True receiver.unregister_handler(self.game.handler_move_left, self.game.handler_move_right, self.game.handler_stop) #---- kong ---- receiver.unregister_handler(self.game.handler_quit)
def test_unregister_multiple_handlers(self): def handler1(): pass def handler2(): pass receiver._handlers['test_event'] += handler1, handler2 receiver.unregister_handler(handler1, handler2) self.assertNotIn(handler1, receiver._handlers['test_event']) self.assertNotIn(handler2, receiver._handlers['test_event'])
def test_unregister_multiple_handlers(self): def handler1(): pass def handler2(): pass receiver._handlers['test_event'] += handler1, handler2 receiver.unregister_handler(handler1, handler2) self.assertNotIn(handler1, receiver._handlers['test_event']) self.assertNotIn(handler2, receiver._handlers['test_event'])
def exit(self, on_exit): """Trigger the animation to return to normal state. Args: on_exit: No-args callable invoked when the laser has converted back to a normal paddle. """ self._to_laser = False self._from_laser = True self._on_exit = on_exit self._laser_anim = iter(reversed(self._image_sequence)) # Stop monitoring for spacebar presses now that we're leaving the # state. receiver.unregister_handler(self._fire)
def __init__(self, game): super().__init__(game) # Bring the ball back onto the screen, but hide it. # This prevents the offscreen callback from being called again. game.ball.anchor(game.paddle.rect.midtop) game.ball.visible = False # Indicate that the game is over. game.over = True # Unregister the event handlers. receiver.unregister_handler(self.game.handler_move_left, self.game.handler_move_right, self.game.handler_stop)
def exit(self, on_exit): """Trigger the animation to return to normal state. Args: on_exit: No-args callable invoked when the laser has converted back to a normal paddle. """ self._to_laser = False self._from_laser = True self._on_exit = on_exit self._laser_anim = iter(reversed(self._image_sequence)) # Stop monitoring for spacebar presses now that we're leaving the # state. receiver.unregister_handler(self._fire)
def __init__(self, game): super().__init__(game) # Bring the ball back onto the screen, but hide it. # This prevents the offscreen callback from being called again. game.ball.anchor(game.paddle.rect.midtop) game.ball.visible = False # Indicate that the game is over. game.over = True # Unregister the event handlers. receiver.unregister_handler(self.game.handler_move_left, self.game.handler_move_right, self.game.handler_stop)
def hide(self): """Hide the start screen and unregister event listeners.""" receiver.unregister_handler(self._on_keyup) self._registered = False self._init = False
def hide(self): receiver.unregister_handler(self._on_keyup) self._registered = False self._init = False
def test_unregister_handler_raises_exception_when_no_handler(self): with self.assertRaises(AssertionError): receiver.unregister_handler()
def exit(self, on_exit): self._to_laser = False self._from_laser = True self._on_exit = on_exit self._laser_anim = iter(reversed(self._image_sequence)) receiver.unregister_handler(self._fire)
def test_unregister_handler_raises_exception_when_no_handler(self): with self.assertRaises(AssertionError): receiver.unregister_handler()
def hide(self): """Hide the start screen and unregister event listeners.""" receiver.unregister_handler(self._on_keyup) self._registered = False self._init = False
def deactivate(self): self.game.paddle.ball_collide_callbacks.remove(self._catch) receiver.unregister_handler(self._release_ball) for ball in self.game.balls: ball.release()