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


Python WindowProperties.set_mouse_mode方法代码示例

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


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

示例1: tick

# 需要导入模块: from panda3d.core import WindowProperties [as 别名]
# 或者: from panda3d.core.WindowProperties import set_mouse_mode [as 别名]
    def tick(self):
        # Select appropriate mouse mode
        if self.constrain_center_mouse:
            mouse_mode = WindowProperties.M_relative

        elif self.confine_mouse:
            mouse_mode = WindowProperties.M_confined

        else:
            mouse_mode = WindowProperties.M_absolute

        # Set mouse mode
        props = WindowProperties()
        props.set_mouse_mode(mouse_mode)
        props.set_cursor_hidden(not self.mouse_visible)
        base.win.requestProperties(props)

        # Get mouse position
        mouse_node = base.mouseWatcherNode
        if not mouse_node.hasMouse():
            return

        x = mouse_node.getMouseX()
        y = mouse_node.getMouseY()

        mouse_position = x, y

        last_mouse_position = self.mouse_position
        if last_mouse_position:
            last_x, last_y = last_mouse_position
            mouse_delta = (x - last_x, y - last_y)

        else:
            mouse_delta = (0.0, 0.0)

        # Set mouse position and delta
        self.mouse_position = mouse_position
        self.mouse_delta = mouse_delta

        # Get event states
        is_down = mouse_node.is_button_down
        active_events = {v for k, v in panda_to_input_button.items() if is_down(k)}
        entered_events = active_events - self._down_events
        released_events = input_button_values - active_events

        # Build converted state
        PRESSED = ButtonStates.pressed
        HELD = ButtonStates.held
        RELEASED = ButtonStates.released

        converted_events = {e: HELD for e in active_events}
        converted_events.update({e: PRESSED for e in entered_events})
        converted_events.update({e: RELEASED for e in released_events})

        self._down_events = active_events
        self.buttons_state = converted_events

        self._world.messenger.send("input_updated", input_manager=self)
开发者ID:agoose77,项目名称:PyAuthServer,代码行数:60,代码来源:input.py

示例2: __init__

# 需要导入模块: from panda3d.core import WindowProperties [as 别名]
# 或者: from panda3d.core.WindowProperties import set_mouse_mode [as 别名]
    def __init__(self, opts):
        super().__init__()

        self.opts = opts
        self.throttle = 1.0 / opts.throttle

        self.loop = asyncio.get_event_loop()
        self.protocol = None
        self.pid = None
        self.world = None
        self.player = None
        self.overhead = True

        self.last_ping = None
        self.latency = 0

        self.set_frame_rate_meter(True)
        self.set_background_color(0, 0, 0)
        self.disable_mouse()

        props = WindowProperties()
        props.set_cursor_hidden(True)
        props.set_mouse_mode(WindowProperties.M_confined)
        self.win.request_properties(props)

        self.render.set_antialias(AntialiasAttrib.M_multisample)

        self.accept('l-up', self.load)
        self.accept('r-up', self.ready)
        self.accept('g-up', self.start)
        self.accept('f-up', self.explode)
        self.accept('tab-up', self.toggle_camera)
        self.accept('mouse1', self.fire)
        self.accept('escape', sys.exit)

        self.taskMgr.add(self.check_mouse, 'check_mouse')

        motion = {
            'w': 'forward',
            's': 'backward',
            'a': 'left',
            'd': 'right',
            '2': 'center',
        }
        for key, cmd in motion.items():
            self.accept(key, self.input, [cmd, True])
            self.accept(key + '-up', self.input, [cmd, False])

        self.a = 0.0
开发者ID:dcwatson,项目名称:pavara,代码行数:51,代码来源:client.py


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