示例#1
0
 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.
示例#2
0
    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'])
示例#3
0
    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'])
示例#4
0
 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)
示例#5
0
    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'])
示例#6
0
    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'])
示例#7
0
    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)
示例#8
0
文件: game.py 项目: wkeeling/arkanoid
    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)
示例#9
0
文件: paddle.py 项目: sanyer/arkanoid
    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)
示例#10
0
    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)
示例#11
0
文件: game.py 项目: wkeeling/arkanoid
 def hide(self):
     """Hide the start screen and unregister event listeners."""
     receiver.unregister_handler(self._on_keyup)
     self._registered = False
     self._init = False
示例#12
0
 def hide(self):
     receiver.unregister_handler(self._on_keyup)
     self._registered = False
     self._init = False
示例#13
0
 def test_unregister_handler_raises_exception_when_no_handler(self):
     with self.assertRaises(AssertionError):
         receiver.unregister_handler()
示例#14
0
 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)
示例#15
0
 def test_unregister_handler_raises_exception_when_no_handler(self):
     with self.assertRaises(AssertionError):
         receiver.unregister_handler()
示例#16
0
 def hide(self):
     """Hide the start screen and unregister event listeners."""
     receiver.unregister_handler(self._on_keyup)
     self._registered = False
     self._init = False
示例#17
0
 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()