本文整理汇总了Python中sdl2.SDL_MOUSEMOTION属性的典型用法代码示例。如果您正苦于以下问题:Python sdl2.SDL_MOUSEMOTION属性的具体用法?Python sdl2.SDL_MOUSEMOTION怎么用?Python sdl2.SDL_MOUSEMOTION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类sdl2
的用法示例。
在下文中一共展示了sdl2.SDL_MOUSEMOTION属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_gui_event
# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_MOUSEMOTION [as 别名]
def on_gui_event(gui, data, event):
"""Callback to react to GUI events.
Parameters
----------
gui : hienoi.gui.GUI
GUI.
data : hienoi.application.OnEventData
Data.
event : sdl2.SDL_Event
GUI event.
"""
if gui.has_view_changed:
# Passing `None` to the `_set_emitter_position` callback resets the
# emitter states, which is what we need here otherwise we might end up
# with crazy values coming out of the navigation actions.
callback = Callback(_set_emitter_position, args=(None,))
data.callbacks.particle_simulation.append(callback)
elif event.type == sdl2.SDL_MOUSEMOTION:
motion_event = event.motion
mouse_position = Vector2i(motion_event.x, motion_event.y)
position = gui.screen_to_world(mouse_position)
callback = Callback(_set_emitter_position, args=(position,))
data.callbacks.particle_simulation.append(callback)
示例2: poll_events
# 需要导入模块: import sdl2 [as 别名]
# 或者: from sdl2 import SDL_MOUSEMOTION [as 别名]
def poll_events(self, scene_state, data=None):
"""Process each event in the queue.
Parameters
----------
scene_state : hienoi.renderer.SceneState
Scene state.
data : object
Data to pass back and forth between the caller and the function set
for the 'on event' callback.
"""
self._has_view_changed = False
event = sdl2.SDL_Event()
while sdl2.SDL_PollEvent(ctypes.byref(event)) != 0:
event_type = event.type
if event_type == sdl2.SDL_QUIT:
self._on_quit_event(event.quit)
elif event_type == sdl2.SDL_WINDOWEVENT:
self._on_window_event(event.window)
elif event_type == sdl2.SDL_KEYDOWN:
self._on_key_down_event(event.key, scene_state)
elif event_type == sdl2.SDL_KEYUP:
self._on_key_up_event(event.key)
elif event_type == sdl2.SDL_MOUSEBUTTONDOWN:
self._on_mouse_button_down_event(event.button)
elif event_type == sdl2.SDL_MOUSEBUTTONUP:
self._on_mouse_button_up_event(event.button)
elif event_type == sdl2.SDL_MOUSEWHEEL:
self._on_mouse_wheel_event(event.wheel)
elif event_type == sdl2.SDL_MOUSEMOTION:
self._on_mouse_motion_event(event.motion)
if self._on_event_callback:
self._on_event_callback(self, data, event)
if self.quit:
break