本文整理匯總了Python中statemachine.StateMachine.onButtonChanged方法的典型用法代碼示例。如果您正苦於以下問題:Python StateMachine.onButtonChanged方法的具體用法?Python StateMachine.onButtonChanged怎麽用?Python StateMachine.onButtonChanged使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類statemachine.StateMachine
的用法示例。
在下文中一共展示了StateMachine.onButtonChanged方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from statemachine import StateMachine [as 別名]
# 或者: from statemachine.StateMachine import onButtonChanged [as 別名]
#.........這裏部分代碼省略.........
controller.set_events(events)
previousControllerState = self.previousControllerState[player]
xAxis = -controller.get_axis(0)
yAxis = -controller.get_axis(1)
previousXAxis = previousControllerState['xAxis']
previousYAxis = previousControllerState['yAxis']
xChanged = previousXAxis != xAxis
yChanged = previousYAxis != yAxis
if xChanged or yChanged:
xAxis, yAxis = self._mapAxisToOrientation(player, xAxis, yAxis)
self.onAxisChanged(player, xAxis, yAxis, previousXAxis, previousYAxis)
previousControllerState['xAxis'] = xAxis
previousControllerState['yAxis'] = yAxis
aButton = controller.get_button(0)
bButton = controller.get_button(1)
cButton = controller.get_button(2)
dButton = controller.get_button(3)
previousAButton = previousControllerState['aButton']
previousBButton = previousControllerState['bButton']
previousCButton = previousControllerState['cButton']
previousDButton = previousControllerState['dButton']
aChanged = previousAButton != aButton
bChanged = previousBButton != bButton
cChanged = previousCButton != cButton
dChanged = previousDButton != dButton
if aChanged or bChanged:
self.onButtonChanged(player, aButton, bButton, previousAButton, previousBButton)
previousControllerState['aButton'] = aButton
previousControllerState['bButton'] = bButton
if cChanged:
if not cButton:
self._onChangeOrientation(player)
previousControllerState['cButton'] = cButton
if dChanged:
if not dButton:
self.onStartMenuTriggered(player)
previousControllerState['dButton'] = dButton
def run(self):
clock = pygame.time.Clock()
while True:
dt = clock.tick(self.framerate) / 1000.0
#dt = time.time() - self.lastFrame
self.update(dt)
self.draw(self.rgb)
self.rgb.send()
self.lastFrame = time.time()
def update(self, dt):
self.poll(dt)