当前位置: 首页>>代码示例>>Python>>正文


Python View.rotate方法代码示例

本文整理汇总了Python中view.View.rotate方法的典型用法代码示例。如果您正苦于以下问题:Python View.rotate方法的具体用法?Python View.rotate怎么用?Python View.rotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在view.View的用法示例。


在下文中一共展示了View.rotate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PoolWindow

# 需要导入模块: from view import View [as 别名]
# 或者: from view.View import rotate [as 别名]

#.........这里部分代码省略.........
                            cue = self.ball['cue']
                            cue.body.clearForces()
                            cue.body.applyGravity()
                            cue.body.applyForce(force, bVector3(offset.x, offset.y, offset.z))

                            # Restore cue
                            self._reset_cue()

        def ball_cant_fly(ball):
            # check for flying
            pos = ball.motion.getWorldTransform().getOrigin()
            if pos.z > ball.radius:
                ball.body.applyCentralForce(bVector3(0, 0, -15 * SCALE_FACTOR))
            # check for ball speed
            v = ball.body.getLinearVelocity()
            vel = eVector3(v.x, v.y, v.z)
            if vel.magnitude_squared() > PoolWindow.BALL_MAX_SPEED:
                ball.body.setLinearVelocity(v * 0.9)

        for ball in self.ball.values():
            ball_cant_fly(ball)

    def on_mouse_press(self, x, y, button, modifiers):
        if button & mouse.RIGHT:
            self.view.zoom_distance = y

    def on_mouse_motion(self, x, y, dx, dy):
        if self.keys[key.LCTRL] and self._cue_ball_rest():
            self.cue.delta = dy * -0.01 * SCALE_FACTOR

    def on_mouse_drag(self, x, y, dx, dy, button, modifiers):
        if button & mouse.LEFT:
            if modifiers & key.MOD_WINDOWS:
                self.view.rotate(dx, dy)
            else:
                self.view.rotate(dx, dy)
                pos = self.ball['cue'].motion.getWorldTransform().getOrigin()
                self.view.set_center(eVector3(pos.x, pos.y, pos.z))
                self.cue.set_position(eVector3(pos.x, pos.y, pos.z + self.cue.pivot.z))
                self.cue.orient_from_direction()
                self._setup_pan()
        elif button & mouse.RIGHT:
            pos = self.ball['cue'].motion.getWorldTransform().getOrigin()
            self.view.set_center(eVector3(pos.x, pos.y, pos.z))
            self.view.zoom(y)
            self._setup_pan()
        elif button & mouse.MIDDLE:
            if modifiers & key.MOD_SHIFT:
                self.cue.move(dx, dy)
            else:
                self.view.pan(dx, dy)

    def _update_scroll(self, dt):
        distance = self.view.distance * self.zmul
        self.view.set_distance(distance)
        pos = self.ball['cue'].motion.getWorldTransform().getOrigin()
        self.view.set_center(eVector3(pos.x, pos.y, pos.z))
        self._setup_pan()
        self.wheel_step -= 1
        if self.wheel_step == 0:
            pyglet.clock.unschedule(self._update_scroll)

    def on_mouse_scroll(self, x, y, scroll_x, scroll_y):
        # Regulate zooming direction depending on scroll wheel direction
        # Schedule scroll update
        self.zmul = .98 if scroll_y > 0 else 1.02
开发者ID:raycode,项目名称:pybilliard,代码行数:70,代码来源:test.py


注:本文中的view.View.rotate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。