示例#1
0
    def cameraMovement(self, task):
        if not self.camFSM:
            return task.done

        if self.camFSM.getCurrentState().getName() == 'frozen':
            if hasattr(self, 'min_camerap') and hasattr(self, 'max_camerap'):
                md = base.win.getPointer(0)
                x = md.getX()
                y = md.getY()
                if base.win.movePointer(0,
                                        base.win.getXSize() / 2,
                                        base.win.getYSize() / 2):
                    self.camPivotNode.setP(self.camPivotNode.getP() -
                                           (y - base.win.getYSize() / 2) * 0.1)
                    self.camPivotNode.setH(self.camPivotNode.getH() -
                                           (x - base.win.getXSize() / 2) * 0.1)
                    if self.camPivotNode.getP() < self.min_camerap:
                        self.camPivotNode.setP(self.min_camerap)
                    elif self.camPivotNode.getP() > self.max_camerap:
                        self.camPivotNode.setP(self.max_camerap)
                return task.cont
            else:
                return task.done

        return FirstPerson.cameraMovement(self, task)