Ejemplo n.º 1
0
    def _update(self, timeSinceLastFrame):
        BaseCommand._update(self, timeSinceLastFrame)

        if self.paused:
            if self.pause <= 0:
                self.finish()
                return
            else:
                self.pause -= timeSinceLastFrame

        if self.is_pressed or self.press_time <= 0:
            state = render_engine._oisMouse.getMouseState()
            if self.pressed and not state.buttonDown(self.button_id):
                state.buttons += (1 << self.button_id)
                render_engine._inputListener.mousePressed(
                    ois.MouseEvent(render_engine._oisMouse, state),
                    self.button_id)
            elif not self.pressed and state.buttonDown(self.button_id):
                state.buttons = state.buttons & (~(1 << self.button_id))
                render_engine._inputListener.mouseReleased(
                    ois.MouseEvent(render_engine._oisMouse, state),
                    self.button_id)

            self.paused = True

        self.press_time -= timeSinceLastFrame
Ejemplo n.º 2
0
 def setMousePosition(self, pos):
     """Sets new mouse position
     
     @param pos:    new mouse position
     @type pos:    (int, int)
     """
     
     state = render_engine._oisMouse.getMouseState()
     
     # create Axes
     state.X.abs = int(pos[0])
     state.X.rel = int(pos[0] - self.current_pos[0])
     
     state.Y.abs = int(pos[1])
     state.Y.rel = int(pos[1] - self.current_pos[1])
     
     render_engine._inputListener.mouseMoved(ois.MouseEvent(render_engine._oisMouse, state))