本文整理汇总了Python中myrmidon.Game.app_loop_callback方法的典型用法代码示例。如果您正苦于以下问题:Python Game.app_loop_callback方法的具体用法?Python Game.app_loop_callback怎么用?Python Game.app_loop_callback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myrmidon.Game
的用法示例。
在下文中一共展示了Game.app_loop_callback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: inputhook_myrmidon_pygame
# 需要导入模块: from myrmidon import Game [as 别名]
# 或者: from myrmidon.Game import app_loop_callback [as 别名]
def inputhook_myrmidon_pygame():
"""The pygame eventloop hook."""
engine_window = Game.engine['window']
if not engine_window:
return 0
for x in Game._module_list:
x._module_setup(cls)
if Game.started:
Game.app_loop_callback(0)
return 0
示例2: inputhook_myrmidon_kivy
# 需要导入模块: from myrmidon import Game [as 别名]
# 或者: from myrmidon.Game import app_loop_callback [as 别名]
def inputhook_myrmidon_kivy():
"""The kivy eventloop hook."""
from kivy.base import EventLoop
from kivy.utils import platform
engine_window = Game.engine['window']
if not engine_window or not engine_window.kivy_app:
return 0
kivy_app = engine_window.kivy_app
if not kivy_app.built:
from kivy.uix.widget import Widget
from kivy.core.window import Window
from kivy.base import runTouchApp
for x in Game._module_list:
x._module_setup(cls)
kivy_app.load_config()
kivy_app.load_kv(filename=kivy_app.kv_file)
kivy_app.root = kivy_app.build()
if not isinstance(kivy_app.root, Widget):
raise Exception('Invalid instance in App.root')
Window.add_widget(kivy_app.root)
# Check if the window is already created
window = EventLoop.window
if window:
kivy_app._app_window = window
window.set_title(kivy_app.get_application_name())
icon = kivy_app.get_application_icon()
if icon:
window.set_icon(icon)
kivy_app._install_settings_keys(window)
else:
raise Exception("Application: No window is created."
" Terminating application run.")
kivy_app.dispatch('on_start')
runTouchApp(kivy_app.root, slave=True)
# Tick forward the Myrmidon event loop one frame
Game.app_loop_callback(0)
# Tick forward kivy to reflect events and changes from Myrmidon.
# This has been directly lifted from `kivy.core.window.window_sdl2`.
EventLoop.idle()
window = EventLoop.window
event = window._win.poll()
if event is False or event is None:
return 0
action, args = event[0], event[1:]
if action == 'quit':
EventLoop.quit = True
window.close()
return 0
elif action in ('fingermotion', 'fingerdown', 'fingerup'):
# for finger, pass the raw event to SDL motion event provider
# XXX this is problematic. On OSX, it generates touches with 0,
# 0 coordinates, at the same times as mouse. But it works.
# We have a conflict of using either the mouse or the finger.
# Right now, we have no mechanism that we could use to know
# which is the preferred one for the application.
if platform == "ios":
SDL2MotionEventProvider.q.appendleft(event)
pass
elif action == 'mousemotion':
x, y = args
x, y = window._fix_mouse_pos(x, y)
window._mouse_x = x
window._mouse_y = y
# don't dispatch motion if no button are pressed
if len(window._mouse_buttons_down) == 0:
return 0
window._mouse_meta = window.modifiers
window.dispatch('on_mouse_move', x, y, window.modifiers)
elif action in ('mousebuttondown', 'mousebuttonup'):
x, y, button = args
x, y = window._fix_mouse_pos(x, y)
btn = 'left'
if button == 3:
btn = 'right'
elif button == 2:
btn = 'middle'
eventname = 'on_mouse_down'
window._mouse_buttons_down.add(button)
if action == 'mousebuttonup':
eventname = 'on_mouse_up'
window._mouse_buttons_down.remove(button)
window._mouse_x = x
window._mouse_y = y
window.dispatch(eventname, x, y, btn, window.modifiers)
elif action.startswith('mousewheel'):
window._update_modifiers()
x, y, button = args
#.........这里部分代码省略.........